3 sys
.path
.insert(0, os
.path
.abspath(os
.path
.join(os
.getcwd(), '..', 'src')))
5 import pyworlds
.worlds
as worlds
6 from pyworlds
.worlds
import sdlconst
,soya
9 head
= worlds
.Body("sword")
11 new_springfactor
= springfactor
= 16
16 pieces
[i
] = worlds
.FollowBody("sword",previous
)
17 pieces
[i
].set_springfactor(new_springfactor
)
20 #worlds.camera = soya.TravelingCamera(worlds.scene)
22 #traveling = soya.ThirdPersonTraveling(pieces[5])
23 #traveling.distance = 35.0
24 #traveling.offset_y = 20.0
25 #traveling.offset_y2 = 10.0
27 #worlds.camera.add_traveling(traveling)
28 #worlds.camera.speed = 0.05
32 global head
, new_springfactor
, springfactor
, vel
34 if sdlconst
.K_UP
in worlds
.KEY
:
35 head
.velocity
.z
=-vel
*2
41 if sdlconst
.K_DOWN
in worlds
.KEY
:
43 if sdlconst
.K_LEFT
in worlds
.KEY
: head
.rotation
[1]+=vel
+1
44 if sdlconst
.K_RIGHT
in worlds
.KEY
: head
.rotation
[1]-=vel
+1
46 head
.rotation
[1]/=1.05
48 if sdlconst
.K_1
in worlds
.KEY
: new_springfactor
=1
49 if sdlconst
.K_2
in worlds
.KEY
: new_springfactor
=2
50 if sdlconst
.K_3
in worlds
.KEY
: new_springfactor
=4
51 if sdlconst
.K_4
in worlds
.KEY
: new_springfactor
=8
52 if sdlconst
.K_5
in worlds
.KEY
: new_springfactor
=16
53 if sdlconst
.K_6
in worlds
.KEY
: new_springfactor
=32
54 if sdlconst
.K_7
in worlds
.KEY
: new_springfactor
=64
55 if sdlconst
.K_8
in worlds
.KEY
: new_springfactor
=80
56 if sdlconst
.K_0
in worlds
.KEY
: new_springfactor
=0
58 if new_springfactor
!= springfactor
:
61 pieces
[i
].set_springfactor(new_springfactor
)
62 springfactor
= new_springfactor
64 def renderloop(proportion
):
66 worlds
.look_at_elastic(worlds
.camera
, head
, sqrt_from
=360, factor
=0.1)
73 worlds
.begin_loop(mainloop
, renderloop
)