Sign in to follow this  
carcan3

tile based skeleton

Recommended Posts

Hi, I need advice about class "architecture" for a basic tile based game. I imagined the following, but I need some expert to tell me if this could be a good design and what can be improved (no AI* is required). That is: could you tell me which methods should I add? Class dataLoader - method: loadData Class Map - method: buildMap(mapArray); - method: getMapHeight; - method: getMapWidth; Class Tile - method setTile; - method getTile; Class Character: - method setCharacter; - method walk(direction); Thanks :-)

Share this post


Link to post
Share on other sites
If your character is bigger/smaller than the tiles and/or doesn't move a tile at a time, you'll want to have a four corners collision routine to see if your player is colliding with a wall.

Share this post


Link to post
Share on other sites
Instead of having a "Character" class, it might be better to have an "Entity" class, and then derive "Character" from it. This will mean that if you want to implement an object that's not stuck to a tile, you could implement a "Object" class to also derive from Entity.

Another thing to consider is will your Tile class represent an individual tile in your map, or a representation of a tile type? If it's a tile type, you'll want to declare Tile as a struct instead as it should be a value and not an object.

Share this post


Link to post
Share on other sites
Hi, first of all thanks.
I forgot to mention I planned to do this with JAVA.

@Ravuya

The character would have the same size of the tile and would move cover an entire tile with one move. I imagined the character class checking for collision in the walk method (is it a bad idea?).

@Rob Loach

The Tile class would create instances of tiles, it would be a tile-type "factory" too.
Ok for the Entity.

Share this post


Link to post
Share on other sites
Question for Rob:

I'm wiring a 2d tile-based game in C#. I'm currently implementing my tiles as structs. Can you elaborate more on the reason one would use structs instead of classes for Tiles?

Wouldn't having an array of pointers to classes be better than an array of copies of structs?

If I'm understanding this wrong, let me know.

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