Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / SPRITE COLLISION error

Author
Message
Leonid
User Banned
Posted: 1st Feb 2013 10:15
DarkBASIC Deluxe 1.09c has an error in SPRITE COLLISION on several machines or OSes. My game highlights this error.
Control: arrow keys, Space forces a flying thought asteroids.

Download

Attachments

Login to view attachments
Latch
12
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 1st Feb 2013 17:40
Hello,

Specifically, what is the error or problem you are talking about?

Enjoy your day.
Leonid
User Banned
Posted: 2nd Feb 2013 00:05
Latch - If you had downloading my game and had finding no problem, please, write here your PC type and OS version.
Latch
12
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Feb 2013 02:30
Leonid,

I don't really know what the game is supposed to do or how it is supposed to play. That's why I need you to tell me what problems to look for. There's no way to tell if it's improper coding or actual problems with the sprites and collision.

Here's something to note about sprite collision in DBC:

Collision is detected when the color channel in the pixel of one sprite overlaps the same color channel in another sprite. if there is no overlap, then there will be no collision detection.

For example, let's say a pixel on a sprite was colored red rgb(255,0,0) and the other sprites pixel color was blue rgb(0,0,255). Let's line them up so we can see if any of the channels match:

255,0,0
0,0,255

No they don't match so even if all of the pixels in one sprite were red, and all of the pixels in the other sprite were blue, there would be no collision detection because none of the channels overlap with a value other than 0.

Now what if one sprite were purple and the other blue:

rgb(255,0,255)
rgb(0,0,255)

You have over lap in the blue channel so therefore there would be collision detection.

IIn order for two sprites to collide, there have to be pixels that overlap in the same channel with values other than zero.

An idea might be to draw an outline around each of your sprites with a dark gray:

rgb(16,16,16)

That way, you'll always have some overlap except if the pixel is absolute black:

rgb(0,0,0)

Enjoy your day.
Leonid
User Banned
Posted: 2nd Feb 2013 03:38 Edited at: 2nd Feb 2013 08:41
Thank you, Latch. I was seeing in test, that only RGB(0,0,0) makes the sprite discollisioned (command answers =0). Some PCs makes sprites collisioned when RGB(0,0,0) has both sprites. I had checking, two source pictures BMP has RGB(0,0,0), not RGB(1,0,0).

Interesting thing, DarkEdit F5 makes the test file with SPRITE COLLISION() problem, but F7 (generates Final exe) makes good code, but another PC any way continue make the problem with running my "good" (on my PC) game.

---

I have one PC with two disks specially soldered to the switch from power supply inside the PC. Every disk works when another does not work. I have two the same WinXP SP 2 on each disk and separately installed DB. These two DB had been generating the same code with SPRITE COLLISION() error.

---

The error, may be, depends on CPU overloading: fast computer has this error, slow - can not find and thinks "all right". Because two other PCs has different results playing my game.

---

Download version without highlighting the collision: astronauts can be captured in free space, and asteroids can be impacted with ship in free space too.

---

If two different PCs shows two different SPRITE COLLISIONs(), I think, there is a video cards uses compression for sprites and rgb(0,0,0) may be lost somewhere inside. I tried to use jpeg pictures for sprites ->> result : rgb(0,0,0) was absenting.

Attachments

Login to view attachments
Latch
12
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Feb 2013 20:40 Edited at: 10th Feb 2013 20:48
jpegs aren't color accurate and if you convert a jpeg to a bmp you'll still have the same color issues.

If you use 16 bit color, then transparency (non collision) becomes an issue up to about rgb(11,11,11) depending on the video card. there is a conversion from 32 bit to 16 bit color that is usually RGB 5,6,5 which means 5 bits are used for red, 6 bits are used for green, 5 bits are used for blue. Different video cards may use other conversion formats like RGB 1,5,5,5 which means 1 bit is used for alpha and 5 bits for each other color channel.

A better way to handle sprite collision might not be by using the collision commands but by building your own collision routine using arrays or memblocks.

That way you can make it consistant.

Also try downloading the latest version (1.2X) of DBC since you are using 1.09c

DBC upgrade

Enjoy your day.

Login to post a reply

Server time is: 2019-06-19 23:57:09
Your offset time is: 2019-06-19 23:57:09