Jump to content

tile based movement for Roguelike game


Recommended Posts

I'm learning Phaser and I starting off with a simple Roguelike game. I had a general question about player movement. Since it's a Roguelike, the player will always be constrained to the tilemap grid. I'm currently handling movement by adding/subtracting the tileWidth/tileHeight of the player sprites x and y positions. I use <mytilemap>.hasTile(x,y,'My Wall Layere')) to check for a wall before moving the player to the new location. I'm not using arcade physics or collisions since I'm manually checking for collisions and enemies before changing location. Does this sound like the correct approach for a Roguelike game?

Link to comment
Share on other sites

Hi @sseligma

Rather than considering sprite sizes (and positions possibly?) wouldn't it be better just to make a check against the underlying tile grid?


If player is at [8, 4] and wants to move to [8, 5] then access grid tile at [8, 5] (this could be map[8][5] if you're using a 2d array like that) and check if the movement is allowed. This has got to be easier than translating to sprite positions and decouples your movement logic from your presentation i.e. what happens if you change the tile dimensions or even the map shape?

Link to comment
Share on other sites

I'm sorry, I'm using a tile grid to determine if an obstacle (tile in a wall layer) exists at that location, and only using the tilewidth and tileheight to control the sprite's position on the screen. The major question I'm trying to determine is should I use arcade physics and collisions for a classic roguelike game. I don't think I do, but wanted to get some other opinions.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...