I've looked at other games with tile based movement. I am aiming to create a game like pokemon, where the player moves smoothly to the next tile.
I am using KeyAdapter, in my KeyInput class. This basically just sets a move speed which is added to the x position of my player in the player's tick function:
if(key == KeyEvent.VK_A && ((Player)object).velY == 0){ object.setVelX(-3); ((Player)object).setDirection(Direction.LEFT); } //The other keys as well... In my tick method, as I said it basically just adds it:
public void tick() { x += velX; y += velY; } And it renders in my render method through Awt Graphics. Anyways, I was wondering how I could make this have tile based movement. Each tile is 32x32 pixels. I've looked at other tutorials and they all seem to have different solutions, I'm not sure it will be compatible with what I'm using a KeyAdaptor. I assume I might have to use a modulus operator to make sure the movement is in tiles.