Skip to main content
gamedev.net
🔒 Locked

2D game ground representation

Started by GameEngineer_gi Feb 26, 2009 at 3:23 PM 3 replies 2.3k views
Original Post
GameEngineer_gi
GameEngineer_gi
Sorry if this has been discussed before, I did my best combing this forum for an answer to this question. I need a way to represent the non-flat ground in a 2d game. Think of games like Robo Slug and Soldat (http://static.soldat.pl/screens/promo/Image4.jpg). Is it just a simple set of connected line segments? Given the players x go get the y using linear interpolation from the retrieved line segment? I've been used to platformer type of orthogonal ground tiles that I'm not sure how non-flat or uneven ground types are represented in the game world. Any thoughts? Steve
JerryM
JerryM
Soldat uses textured triangles (think 3D) to represent the game world. From there, I imagine that a simple set of physics subroutines handles positioning.
Hazard org
Hazard org
Yes, i know what you're talking about. Some years ago (back in 2003 I think... ) I found this great open source game made in Turbo Pascal, a clone of old Wolfenstein 3D game. The big drawback would probably be the differences between Pascal and OOP, but you can handle that I suppose :)

Just a tought, hope it helps... Try this It's an engine that explains the basics of Wolfenstein, with source code and comments, but... Pascal. I didn't play Soldat before but I'm preety sure that if you get this working you can further develop to do something similar to that screenshot I just saw.

Good luck!
jdindia
jdindia
Usually it's either some string of edges or a bunch of convex shapes. If you're doing physics, I'd recommend just using Box2d or Chipmunk.

If you don't like libraries, well, in general you solve these sorts of things using vectors, not 'functions in y'. There are many, many different ways of going about it. Very roughly you want to model your objects as circles/convex polygons. You'll need a way to determine collisions between things, the point where the collision happened and some kind of normal (probably the corresponding ground normal). From there you'll probably want to project the offending objects out of the terrain they're colliding with.
GameEngineer_gi
GameEngineer_gi
Thanks guys!

I'm playing around with Box2d to see if I can get a, believe it or not, fake looking platformer type of player jump to work. I don't want it to look real, I want it to look fake. :)
I'm hoping I can tweak the physical properties enough to where it works then I get the collision detection for free!

Regardless of whether I roll my own collision detection or use an sdk you have convinced me to use polygons for the ground. The top edge of the poly will be used for collisions just as if it were a 3D game where the top edge of the terrain is used.

Steve

Topic Locked

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

Sign in to reply to this topic.