Sign in to follow this  
proanim

storing level data

Recommended Posts

I am looking to create 2D game (maybe RPG, maybe rogue-like, maybe both biggrin.png), but i am facing a problem coming up with a solution for storing level data. I want to create initial level structure through tile system, but I don't want game it self to be dependent on tiles.

 

All levels can be created with tiles, that is tiles for ground, walls and other stuff, but than I would like player and other characters to be moving in freely without being constrained tiles and have fallout type zig-zaging and such. What confuses me is the fact that tiles that were used to construct the level would be written in a file in a way that would make sense to a human.

 

How should i go around storing data for a character's position if its not constrained to tiles? 

Share this post


Link to post
Share on other sites

Tiled level layouts do not mean movement has to be from tile to tile. You can still have positions stored as float, and adjust position gradually within a tile, without having to snap to up/left/right/down tiles on movement.

 

In a topdown (non-isometric) level, with each tile being e.g. 128x156 pixels in size, you can move around as if the level weren't tiled. You can, however, use the tile system to figure out e.g. collisions.

Using some simple math you can figure out which tile you're standing on, and only check for collisions or whatever in tiles that are adjacent (or otherwise interesting).

In this case, you could figure out the tile by using pos.x / 128 and pos.y / 156.

 

This also works for isometric layouts, but the math is (slightly) more involved.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this