Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Tile Based Movement  (Read 4066 times)

0 Members and 1 Guest are viewing this topic.

xilo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Tile Based Movement
« on: August 21, 2010, 05:02:02 am »
I'm having difficulties trying to figure out tile based movement and animation.

I'm wanting to create a tile-based RPG with movement similar to Pokemon, FF2,3,4, etc where say if you press left key, the character will move only only one tile to the left and it's sprite will animate through however many sprites you want. If you continue to hold the left key, the character will continue to move one tile to the left and the sprites will cycle through the full animation.

All I've really seen are tutorials for smooth movement and such, but nothing to really mimic this behavior.

Any help me out?  :cry:

Kingdom of Fish

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Tile Based Movement
« Reply #1 on: August 21, 2010, 12:25:41 pm »
You just set the position, my tip is to divide the screen or area of the game into squares of something like 16px and then you just set the position by sprite.SetPosition(grid_x*16, grid_y*16);

xilo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Tile Based Movement
« Reply #2 on: August 21, 2010, 09:05:35 pm »
I sort of figured out how to do it, but I have one glaring problem.

Sometimes, the sprite will skip a block if I'm just tapping on the arrow key.
Normally, just tapping will move the character one block, but sometimes it moves the character 2 blocks.

I have this set:

Code: [Select]
App.SetFramerateLimit(60);

I'm guessing the tile skipping has something to do with the FPS and time between frames and slight hiccups?

What formula do I need to do for the character movement to fix this problem?

Finn

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
Tile Based Movement
« Reply #3 on: August 21, 2010, 09:32:49 pm »
Code: [Select]

window.EnableKeyRepeat(false);


should fix it.

xilo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Tile Based Movement
« Reply #4 on: August 21, 2010, 09:57:32 pm »
Nope, I still get periodic 2 tile jumping. I'm using 1.6 btw since 2.0 has a huge problem with ATI cards.

xilo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Tile Based Movement
« Reply #5 on: August 21, 2010, 10:26:55 pm »
Edit: Got it fixed.