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 *
11 head
= PhysicsBody(mesh_file
="sword")
16 new_springfactor
= springfactor
= 16
21 pieces
[i
] = w
.FollowBody("sword",previous
)
24 w
.camera
.set_xyz(0,35,25)
25 w
.camera
.look_at(head
)
28 global head
, new_springfactor
, springfactor
29 if soya
.sdlconst
.K_UP
in w
.KEY
:
30 head
.speed
.z
-=1; head
.speed
.z
*=0.99
33 if soya
.sdlconst
.K_DOWN
in w
.KEY
:
35 if soya
.sdlconst
.K_LEFT
in w
.KEY
: head
.rotation
[1]+=200
36 if soya
.sdlconst
.K_RIGHT
in w
.KEY
: head
.rotation
[1]-=200
39 if soya
.sdlconst
.K_1
in w
.KEY
: new_springfactor
=0.1
40 if soya
.sdlconst
.K_2
in w
.KEY
: new_springfactor
=0.2
41 if soya
.sdlconst
.K_3
in w
.KEY
: new_springfactor
=0.4
42 if soya
.sdlconst
.K_4
in w
.KEY
: new_springfactor
=0.8
43 if soya
.sdlconst
.K_5
in w
.KEY
: new_springfactor
=1.6
44 if soya
.sdlconst
.K_0
in w
.KEY
: new_springfactor
=0
46 if new_springfactor
!= springfactor
:
49 pieces
[i
].set_springfactor(new_springfactor
)
51 new_springfactor
= springfactor
53 def renderloop(proportion
):
55 w
.camera
.look_at(head
)
62 w
.begin_loop(mainloop
, renderloop
)