Tile movement script.. controls controls break at runtime

Hi,

I’m trying to make some simple tile movement script a la oldschool dungeon master
I manage to write this but it’s very badly done, I’m sure it can be solved more elegantly :o (I’m bge lame, not mention about any programing skills)

bigest problem is that if you make full 360 degree turnaround all controls stop to work :confused:

please can someone have a look? thanks

I’m planing also some ray testing for walls and floor properties to restrict thru walls walking and air/water walking…, also I would like to add some simple automapping and compass
I appreciate any tips and pointers :slight_smile:

Attachments

tilemovement_alpha01.blend (401 KB)

the things you try to do can be done more easily with just logic, so is there a reason you want to use a python script?

dj2k i would like to see you do this in logic.

Here, I could of done it in logic too, but this was easier for me.
tilemovement.blend (345 KB)
Just use a ray to detect the walls and add that to the script, should be easy enough to figure out. Oh yeah, and my rotation number only works for a few hundred thousand consecutive clicks in the same direction, then it might be rotated off by 1 degree ;). I don’t know what applyRotation takes, obviously not degrees. So I had to use a weird number found via trial and error: 1.570796329 anyone know where this number originates?

http://processing.org/reference/HALF_PI.html

dj2k: I don’t know how to change position via logic bricks to achieve this kind of tile jumping and I though it would be nice if I can manage something in python

Mad Hatteur: many many thanks, I was hoping for such elegant solution :slight_smile:

dbigers: can halfpi be used in bge python?

psychotron: ever heard of radians?

They’re like degrees, but a different scale. So instead of being 360 degrees, a circle is 2*pi radians. (roughly 6.28)

Thus, 1/4 of a circle, 90 degrees is pi/2 radians (roughly 1.570796329 )

to use pi in python just do

from math import pi

and you now have a fairly accurate variable that is pi.
replace your crazy variable with pi/2

thanks for code
I already try to replace it with pi/2 but doesn’t work - I don’t know I must import it from math module