Skip to main content
GameDev.net gamedev.net
🔒 Locked

Landscape, scroll and collision detection

Started by computerphysicslab Jan 10, 2010 at 11:32 AM 1 replies 1k views
Original Post
computerphysicslab
computerphysicslab
Hi, all, I am trying to design a 2D game that needs the screen to scroll from left to right and right to left according to the character movements. I want the floor to be a wrinkled surface with small mountains and cliffs, hollows, etc. What is the easiest way to create such a landscape and use it within a game? Which file format would be the best for storing this kind of maps/surfaces? Is it easy to implement collision detection between the character and the floor/landscape? Thanks in advance. Any hint would be appreciated.
Samith
Samith
Well, there are tons of ways to do this. Personally, I think the easiest, most flexible and best performing way to do it would be to store your terrain as a 2d polygon. Collision between the player and the terrain is just a matter of checking if the player is within the polygon, which is really just a matter of checking if the player is within a triangle of the polygon.

Another option is a tile based map, which is good and easy to do. You could have different types of tiles for collision detection purposes, for example one tile type could be completely solid, another completely open, and yet another could be "half open" where only the bottom right triangle of the tile is solid, or something like that.

It's really up to you. There is no one defined file type for this type of thing, you'll probably be best off writing your own files the way you want them.
computerphysicslab
computerphysicslab
Thanks. I find it easier the tile based map. I find some problems about the polygonal way. The idea is the landscape is big, around 10 screens of with from side to side. How am I going to manage a so big polygon? Using maybe some kind of editor that lets me to move every corner of the polygon from one place to another until getting the desired landscape?

I guess that the polygon would be mainly like a big rectangle, but adding small triangles over the top side. So, the top side would be the floor. Is that correct?

In that case, it would be like having just a set of triangles in several layers, each above others, until form like a big irregular star.

I find another problem in both schemes, that the resulting surface is not smooth because of the corners. Probably I would like some areas to be smooth, like curves. Is there any way to smooth the tiles when joining, or the triagulum's corners?

Thanks again.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.