Monday, May 28, 2012

Map

Now that I finally started this blog, I can go back and highlight some of the things I've already done. We'll look at the Map class. The map is composed of blocks, and at the moment there are six types of blocks (air, ground, and 4 orientations of triangles).

This is my first large project in Java, so this is a learning experience. I spent quite a bit of time trying to decide which class "knows" the block position and height. For a while I thought that a block should know these things, but it just wasn't working the way I wanted to. So, I landed on the map owning these state variables.

The Map class takes a .txt file and outputs a .map file and a .png. I will allow users to create their own maps.

Let's look at an example:

this text:

111111111111111111111111111111111111111111111111111
110000000000000000000000000000000000000000000000001
110000000000000000000000023000000000000000000000001
110000000000000000000000054000000000000000000000001
110000000200000000000000000000000000000000000000001
111111111100000000000000000000000211100000000000001
111111111111111111111111111111111111400000000000001
110000000000000000000000000000000000000000000000001
110000000000000000000000000000000000000000000000001
110000000000000000000000000000000000000000000000001
110000000000000000000000000000000000000000000000001
110000000000000000000000000000000000000000000000001
110000000000000000000000000000000000000000000000001
110000000000000000021111111111300000000000000000001
111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111

Makes this image.
This is the image that I used in the bouncy physics demo. The screen doesn't move with the player yet. I know I'll have to implement this to do it, though.

I have yet to decide on how I will handle the number of blocks on screen at a time. It should probably scale with velocity of player but for now, it'll be static. I should probably zoom out from what I had in the physics demo yesterday (26 blocks wide, 14 blocks tall).

No comments:

Post a Comment