Author Topic: Collision Detection  (Read 661 times)

Offline keybone

  • My name a Nursultan Tulyakbay. I get iPod Mini!
Re: Collision Detection
« Reply #30 on: July 08, 2018, 02: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.
My neighbor Borat he a pain in my assholes. I get a window from a glass, he get a window from a glass. I get a step, he must get a step. He get clock radio I cannot afford!

Online FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: Collision Detection
« Reply #31 on: July 08, 2018, 03: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.

Re: Collision Detection
« Reply #32 on: July 08, 2018, 08: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: [Select]
SCREEN _NEWIMAGE(800, 600, 32)
PSET (0, 0), -1 'bright white (_RGB32(255,255,255))

DIM k AS LONG, k1 AS _UNSIGNED LONG
PRINT POINT(0, 0) 'How QB64 reports it naturally
k = POINT(0, 0) 'what we'd store it as, if we store it as a LONG
k1 = POINT(0, 0) 'how we'd store that value as UNSIGNED LONG
PRINT k, k1 'print to illustrate the different values

IF k = POINT(0, 0) THEN PRINT "LONG TRUE" ELSE PRINT "LONG FALSE" 'and how they change behavior with IF
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.

Offline keybone

  • My name a Nursultan Tulyakbay. I get iPod Mini!
Re: Collision Detection
« Reply #33 on: July 09, 2018, 02: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, 02:22:30 PM by keybone »
My neighbor Borat he a pain in my assholes. I get a window from a glass, he get a window from a glass. I get a step, he must get a step. He get clock radio I cannot afford!