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 / 2d Platform Game - Collision detection

Author
Message
Stoddsie
15
Years of Service
User Offline
Joined: 21st Aug 2009
Location:
Posted: 21st Aug 2009 23:19
Hi Everyone. Whilst not a newbie coder as such, I am certainly a newbie in game development. I have written a routine which renders a tile map using sprites - simply because I wanted to use the built in collision routines. However, I am not convinced this is the correct approach, and is surely a bad use of sprites and memory.

I would much rather use tiled images and use dbPasteImage() for example to render my screen. However, this means I need to implement some kind of custom collision detection to determine where my player can walk, and where they can't.

My map currently is an array eg map[20][15]. and for brevity purposes looks like the following:
0,0,0,0,0
0,0,0,0,1
0,0,0,0,1
1,1,1,1,1 (where 1=solid ground, 0=air)


I can ascertain which map tile my player is currently in. Would I be on the right track by testing the adjacent tile around me (above, below,right,left) and depending on whether the tile is solid, allow my player to pass or force him to stop.

I guess for me the problem with game development is knowing the best way to do something, or the way in which most common games are written.

I'd be very grateful for any advice, or links to tutorials or example code that may help me grasp these concepts.

Cheers

Stoddsie
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 23rd Aug 2009 20:29
Both the sprite-based and the image-based approaches will work. The method you describe for map-based collision detection is good as well. I would say do what you feel is best for your game, what fits into the design.

There was a newsletter serial about making a platform game, but it is for DB Pro. I've always been planning to read this serial, never had the time, so I don't know how much of it is applicable to Dark GDK. Here is the link to the issue of the newsletter which has links to all parts, maybe it will be interesting for you:

http://darkbasicpro.thegamecreators.com/data/newsletter/newsletter_issue_76.html

Login to post a reply

Server time is: 2024-11-20 17:24:15
Your offset time is: 2024-11-20 17:24:15