bugfix
[pyworlds.git] / tests / keyboard.py
blob1482c1588325b43871f67cc871b6b765d0505495
1 #!/usr/bin/python
2 import sys,os
3 sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), '..', 'src')))
5 import pyworlds.worlds as w
6 from pyworlds.basics.body import *
7 from soya.sdlconst import *
9 w.init()
11 sword = PhysicsBody(mesh_file="sword")
13 sword.rotation[1]=90.0
14 sword.rotation[0]=17.0
15 sword.rotation[2]=3.0
16 w.camera.set_xyz(0,0,5)
19 time = 0
21 @sword.addloopcall
22 def swordloop(t):
23 if t==0: return 0;
25 if K_UP in w.KEY: sword.rotation[0]+=200*t
26 if K_DOWN in w.KEY: sword.rotation[0]-=200*t
27 if K_LEFT in w.KEY: sword.rotation[1]+=200*t
28 if K_RIGHT in w.KEY: sword.rotation[1]-=200*t
29 if K_RSHIFT in w.KEY: sword.rotation[2]+=200*t
30 if K_RCTRL in w.KEY: sword.rotation[2]-=200*t
32 sword.rotation[0]/=1+0.50*t
33 sword.rotation[1]/=1+0.50*t
34 sword.rotation[2]/=1+0.50*t
35 return t
38 w.begin_loop()