About Store Forum Documentation Contact

Post Reply 
2D game map
Author Message
AndrewBGS Offline

Post: #1
2D game map
I was wondering how I would go about crating a non-linear terrain for a 2D game that I want both to have a nice texture on and can be used for collision;

Like the ground in games like "Hill Climb Racing".
How would I go about creating this efficiently?
(so I need to make the terrain "map", then draw it nicely, and handle collision on it)
05-09-2014 10:28 AM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline

Post: #2
RE: 2D game map
Hi Andrew, I'm not sure what support is already included in Esenthel for 2d based collision (if any) but I got my name from a 2D technique call Pixel Perfect Collision and here is a link to a C++ routine I quickly found using Google. I assume you'll be using sprites if its a true 2D game:

PP Collision routine

I've not spent any time looking at it so can't vouch that it works or the quality of it but its an example of what 2D designers tend to use.
05-09-2014 11:01 AM
Find all posts by this user Quote this message in a reply
TBJokers Offline

Post: #3
RE: 2D game map
I've worked with alot of 2D for personal projects, something that i found most helping when it comes to Physics is this link


Very good if you want to learn alot of how things work, and also try your math skills..

Optimizations such as do not use Sqrt instead *= and ^2 etc. Are things that i found interesting and that i would personally not think about.. This might however not be the easiest but it's one of the better.
Side note is also that you can get the pixels height of the image for each pixel and then when doing that sorting them so that similar pixels are stored in a linear ordered array and basically turn the players position into pixel co-ordinates and compare it to your lineared array using binary search?


And as for the array being big you could always go through the array and check if there are X elements in a row that are currently the same height and merge them and store a float width.
(This post was last modified: 05-09-2014 11:11 AM by TBJokers.)
05-09-2014 11:07 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply