FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: Keyboard Movement  (Read 1321 times)

Toetag

  • Newbie
  • Posts: 1
    • View Profile
Keyboard Movement
« on: April 05, 2013, 05:57:34 pm »

I want to make the player character from tutorial1d movable by using WASD-keys. I have come pretty far but now I am a bit stuck. I could not find an Instance.move()-method only taking direction and speed as arguments, but one working with a target-location, as used in the tutorial.
I actually got it working but it is a poor workaround.

In case there is no such method somewhere under the hood I will explain what I have got so far:
I cloned the player-instance's Location, moved it relatively up/down the x/y axis and made the player character move to this location as long as the corresponding keys are pressed. As supposed to, the player character moves up while pressing W, down on S and so on, even the animations are acceptable. BUT... if I stop the character between two cells and then change direction, the character first slides sideways until it snaps on a cell-row or a diagonal. In a mouse-controlled context the pathing system is a huge advantage but for "direct" key-control it feels kinda squishy.
What I would expect for the final result is either the character to not stop between two cells and keep walking until the next one or (preferably) to just go straight ahead even between cell-rows.
I would appreciate any hint on this.

Many thanks in advance!
« Last Edit: April 05, 2013, 06:00:26 pm by Toetag »
Logged

helios

  • Developer
  • Jr. Member
  • *
  • Posts: 60
    • View Profile
Re: Keyboard Movement
« Reply #1 on: April 07, 2013, 12:01:49 pm »

Hey Toetag,
it depends on your implementation. What sort of coordinates you are using?
The center of a cell are always integer layer coordinates (location.getLayerCoordinates()), so 5,4 means the instance stand in the center of the cell. Exact layer coordinates describe the exact position, e.g. if the instance is on the edge between 5,4 and 6,4 the exact layer coordinates are 5.5,4.
Logged