Need input for 2d Level Modeling


I’m still in the development of my 2D top-down game, and I’m getting to the point where I need to start considering my level design. I have my functional requirements mapped out as such:

1: Be able to detect collisions given moving elements that have a collision shaped defined by simple shapes (circle, square, triangle)
2. Be able to calculate an outgoing trajectory, considering an element hitting the walls with an in-going trajectory (much like snooker)
3. Be able to create levels algorithmically or textually (not necessarily procedurally). A scene could be considered if it makes sense given a set of tiles/some way to ‘draw the level’ (but much rather create the level in code)
4. Be able to define different properties for different sections of the ‘walls’ (ie. passable or other such functions)


  1. Granularity that makes any out-going trajectory possible considering any in-going trajectory (ie. curved, smooth walls and jagged, spiky walls). Further explenation:
  2. Give walls different kinds of textures/tiling
  3. Define sections of the level by mathematical functions. Could perhaps make collisions detection easy - just insert coordinates into the function to check (not sure). Examples

The inspiration for my game is Subspace (old school game), and the level design is a big turning point here. However, one factor I want to improve in my game, is the granularity of the levels. In Subspace, There are 16 pixel blocks, with clever tiles that makes the walls appear diagonal (but they are not):

a. If I fire (non-perpendicularly) at a diagonal wall in Subspace, the inner angle of my bouncing shot will be 90 degrees or less (hope that makes sense). I would like it possible that it could be up to <180 degrees. Now, if I fire at a vertical or horisontal wall in Subspace, the inner angle can be <180 degrees as expected. I think it comes down to granularity, collision shape(s), collision detections and trajectory calculations. I’m looking for input on how to get started.
b. If I fire perpendicularly at a diagonal wall in subspace, my shot will come straight back (given that it can bounce twice) because it bounces of two blocks.

Hope that makes sense - I’ll update if I think of ways to solve them. I haven’t dabbled much in this area before, so will have to do some research.

Let me know if anything is unclear :slight_smile:

Are you looking for what to use to do physics/collisions? Because if so then I can HIGHLY recommend dyn4j as a 2D physics solutions.

It’s really great.


I’ll keep that in mind, but first im looking for input on how to model the level, so that I have something to collide with :slight_smile: I’ll return here if I come up with something.

dyn4j supports polygon collision shapes so you can pretty much do whatever you want with respect to level design… just have to be able to map it to polygons. It also supports simpler shapes, of course.

My GMath library for jME has a vector reflect method, you just pass in the direction vector of the colliding object and the normal vector of the surface it collided with and it returns a vector that is the direction reflected by the normal.

P.S. I can also vouch for the quality of Dyn4j, very easy to work with.

1 Like

Currently I’m using a polygon Geometry that is then checked with JME spatial Collision (Geometry.collideWith). No physics involved.

But I think that sometimes the collision isn’t detected… should I switch to dyn4j?

dyn4j is 2D. If your shapes are 2D then you should use it.

But it’s a whole 2D physics engine and it’s pretty nice.