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.

Dark GDK / Per-Pixel Collision

Author
Message
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 21st Oct 2008 00:18 Edited at: 21st Oct 2008 00:32
It's really simple, probably ineffective, untested, won't work with scaled, rotated, or stretched sprites, and requires you use a colorkey or something.

I hope it's not illegal to name it with the db prefix. I did that for simplicity.



Fixed a couple syntax errors. I'm bad at that.
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 21st Oct 2008 00:22
Quote: "It's really simple, probably ineffective, untested, won't work with scaled, rotated, or stretched sprites, and requires you use a colorkey or something."

Untested, colorkey or something? Is this your code?

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 21st Oct 2008 00:23 Edited at: 21st Oct 2008 00:24
Yep, it's mine. I meant by that, you need to specify which color is considered transparent, so it doesn't test collision on that color.

I'm lazy, I wrote it for SushiBox. I'm a little busy, can't take the time to set up something to test it. Sorry.
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 21st Oct 2008 00:34
Woot I'm special! :3

www.Helios-Online.net
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 21st Oct 2008 06:11
Update: I am testing this with a single image overlay for setting up a collision mapping layer by color. A quick way to do this is create your whole level on one image and replace the transparent section of your .PNG with the selected color key. I am going to further work on this. Once completed and perfected, this should really be added to the DarkGDK library. Per pixel collision is a vital building block in any 2D game.

This makes traveling up slopes/hills in 2D Side Scrolling games much easier. Also less intensive than calling each image for collision. Kudos to Zuka for the code.

www.Helios-Online.net
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 21st Oct 2008 06:44
Knowing full well that I'm not going to have time to respond to this before I leave for vacation I'm going to offer the following.

Forget about pixel collisions. Use an internal map of your own design. If it's tile based just keep track of the beginning and end points of the tile and have a structure that describes the nature of the surface or obstructions within each tile type. Program around this rather than trying to extract pixels from the screen.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-11-25 06:45:24
Your offset time is: 2024-11-25 06:45:24