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 / Collision Detection Problem

Author
Message
DaNuTz
13
Years of Service
User Offline
Joined: 10th Feb 2011
Location:
Posted: 10th Feb 2011 16:34
Hi Everyone.I'm certainly a newbie in game development and also not very warm with C++.I start using DGDK 2 weeks ago , in my attempt to make the Donkey Kong Game.So far I have the first Mode of the game..the one with the message "HOW HIGH YOU CAN GET?" also some sounds and Input.When FIRE is pressed the game switch to the second Mode ..the mode with the background image(the slopes and stairs ) i managed to make the barrels fall on the slopes and the monkey moving accordingly with barrels movement. but i'm stuck at Collision Detection. I didn't find tutorials or at least some code snippets to make me an impresion of how collision detection should work. I read someware that i can make collision detection using a background image under the original background image drawed with blue for the slopes and red for the stairs. Ok , i can do in photoshop that image but still i don't know how am i supposed to convince mario walking on the blue parts and climbing on the red parts of the image.
Thanks in advance for any suggestions and help.
P.S have mercy on me

danutz
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Feb 2011 02:27
An easy way around this problem is to have your background as normal. But have a copy of it in memory (let's say just black and white) which looks like a stencil of all the areas which are collidable with. Each time you go to move an object around the screen just check a pixel forward of the movement. If the pixel is set then the object cannot go that way.

Warning! May contain Nuts!
Superdeath360
13
Years of Service
User Offline
Joined: 23rd Nov 2010
Location:
Posted: 7th May 2011 17:57
I know this is old, but how exactly do you do what you described, W:Gfx?

herp derp
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 8th May 2011 14:41 Edited at: 8th May 2011 14:43
What I described is the old hat method of collision detection. Using Dark Basics sprites would be much easier as everything on the screen being drawn can be checked using the built in commands.

My method would need this:

create a bitmap using the same size as the screen
draw all objects to it that would be collidable

In your main loop:

before moveing player then check the copy bitmap if the player would collide

Then just draw your screen as usual

draw background
draw level objects
draw baddies
draw player

Using sprites methods would just simply need something like: (I've not used 2d yet)

if sprite_collision(sprite1, sprite2) {
do something
}

and that's it.

There are some examples that come with DBP and GDK that use the sprite commands and collision. Reading through them should give you a good start. Hope you get somewhere with it soon.

Warning! May contain Nuts!

Login to post a reply

Server time is: 2024-10-02 17:26:04
Your offset time is: 2024-10-02 17:26:04