Author Topic: Collision Detection  (Read 12944 times)

0 Members and 1 Guest are viewing this topic.

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Re: Collision Detection
« Reply #30 on: July 08, 2018, 01:58:51 pm »
The & is for long integer type best used with _RGB32 color variables, use && if want alpha too ie _RBGA32().


Actually, you could use ~& or _UNSIGNED LONG to get _RGBA32 too, will probably save a bit of memory.
I am from a Kazakhstan, we follow the hawk.

FellippeHeitor

  • Guest
Re: Collision Detection
« Reply #31 on: July 08, 2018, 02:58:20 pm »
Yeah, there's definitely no need for _INTEGER64 (&&) to store colors, even with transparency. Long (or unsigned long) is more than enough.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Collision Detection
« Reply #32 on: July 08, 2018, 07:16:31 pm »
Yeah, there's definitely no need for _INTEGER64 (&&) to store colors, even with transparency. Long (or unsigned long) is more than enough.

Personally, I advocate *ALWAYS* using _UNSIGNED LONG for color values.  The reason should be apparent in the little code snippet below:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. PSET (0, 0), -1 'bright white (_RGB32(255,255,255))
  3.  
  4. PRINT POINT(0, 0) 'How QB64 reports it naturally
  5. k = POINT(0, 0) 'what we'd store it as, if we store it as a LONG
  6. k1 = POINT(0, 0) 'how we'd store that value as UNSIGNED LONG
  7. PRINT k, k1 'print to illustrate the different values
  8.  
  9. IF k = POINT(0, 0) THEN PRINT "LONG TRUE" ELSE PRINT "LONG FALSE" 'and how they change behavior with IF
  10. IF k1 = POINT(0, 0) THEN PRINT "UNSIGNED LONG TRUE" ELSE PRINT "UNSIGNED LONG FALSE"

If you're going to use POINT at all in your code, make certain you compare its values against UNSIGNED LONG values.  Otherwise, you're going to end up with a lot of false results which are going to make your program harder than heck to debug and work properly in the future.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Re: Collision Detection
« Reply #33 on: July 09, 2018, 01:20:10 pm »

Personally, I advocate *ALWAYS* using _UNSIGNED LONG for color values.


I agree 100%, no point in wasting space and potentially causing errors at the same time.

Maybe that guy either didnt realize about _UNSIGNED or he didnt realize that the number

signing was the only thing stopping the color value from fitting in a LONG variable.
« Last Edit: July 09, 2018, 01:22:30 pm by keybone »
I am from a Kazakhstan, we follow the hawk.