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 / Background Sprite Collision by Color

Author
Message
gwin003
11
Years of Service
User Offline
Joined: 22nd Jun 2012
Location:
Posted: 25th Jul 2012 04:48
I am using DarkGDK.NET, but that forums is a lot less active than this one. So I am duplicating this here...

I am working on a topdown 2D game in which the background (floor) of the map uses another sprite which is a collision map. The collision map is white where the player can move, and black where he cannot. I want the player to be able to move where the collision map is white, but run into a wall when it is black.

I could use transparency if it will make this easier. Does anyone have any good tutorials on how to do this in DarkGDK.NET? Thanks!
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 25th Jul 2012 12:28
Pixel Perfect collision isn't built into DarkGDK unfortunately.
If you won't have to rotate your collision map I'd suggest you to tuen it into a memblock (or just use dbGetImagePointer(imageID) / whatever it's called) to access the individual pixels and then check against their colours / alpha map at the position where your characters are.


"Why do programmers get Halloween and Christmas mixed up?"
gwin003
11
Years of Service
User Offline
Joined: 22nd Jun 2012
Location:
Posted: 27th Jul 2012 05:33
I won't have to do any rotations of the background map, but the player will obviously be able to rotate. I think I am going to try to incorporate a collision sprite into the player so I have a round circle to use for the player collision.

OR, I might try calculating and storing a circle. Then checking the edges of the circle for collisions... Not sure if this will work but going to give it a shot...

Login to post a reply

Server time is: 2024-04-16 09:12:48
Your offset time is: 2024-04-16 09:12:48