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: Vertical movement (moving things in the z-axis, up/down)?  (Read 944 times)

1cyborg

  • Newbie
  • Posts: 2
    • View Profile
Vertical movement (moving things in the z-axis, up/down)?
« on: January 06, 2014, 09:53:23 am »

TL;DR: I'm trying to move characters (instances in FIFE parlance?) up and down (in the z-axis), but stuck on how to do so.

I'm currently using the map and skeleton from the tutorial1c, but changed a bunch of the code from that tutorial to be more in line with the shooter demo so that I can use WASD keys for movement instead of clicking. I've got the player moving in the x/y axes with WASD well, and I'm essentially doing that using:
Code: [Select]
                curloc = self.location
                exactloc = curloc.getExactLayerCoordinates()
followed by
Code: [Select]
                elif self._scene.keystate['S']:
                        exactloc.y += 1 # SOUTH
                        self._statechanged = True
followed by
Code: [Select]
                curloc.setExactLayerCoordinates(exactloc)
                self._location = curloc
followed by
Code: [Select]
                if self._statechanged:
                        self._instance.move('walk', self._location, 4.0)


I want to raise/lower the skeleton/character using the E and R keys, respectively. My first (and only) thought is to essentially use the same type of system because it worked for x/y:

Code: [Select]
                elif self._scene.keystate['E']:
                        exactloc.z += 1 # UP
                        self._statechangedZ = True
followed by
Code: [Select]
                if self._statechangedZ:
                        self._instance.move('stand', self._location, 4.0)
with the curloc bits the same as before (it's all in the update function which I can post if desired).

This doesn't work. I'm printing exactloc to the console, and exactloc's z value does change when the E key is pressed, but reverts back to 0 as soon as it is released, like so:
DoublePoint3D(0:1:1)
DoublePoint3D(0:1:0)

What I'm looking for is a way to have the player ascend/descend. I'd prefer the result be some sort of motion in the x,y,z grid, but if it isn't possible, simulating up/down movement would also be fine I think. Any pointers?

(I do some scripting for my job, so coding isn't foreign to me, but python is - learning python is part of the reason I'm undertaking a little project and may just be missing something obvious. Thanks!)
Logged