sseligma Posted July 28, 2017 Share Posted July 28, 2017 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 More sharing options...
mattstyles Posted July 28, 2017 Share Posted July 28, 2017 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? i.e. 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 More sharing options...
sseligma Posted July 28, 2017 Author Share Posted July 28, 2017 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 More sharing options...
mattstyles Posted July 28, 2017 Share Posted July 28, 2017 I'm not sure you need to use a dedicated physics engine for a roguelike with tile-by-tile movement no. I'm sure it would work, just not convinced its worth the effort. Link to comment Share on other sites More sharing options...
Recommended Posts