Line | |
---|
1 | -- Get objects from orxonox |
---|
2 | thisscript:addObject("TestEntity", "fallingguy") |
---|
3 | thisscript:addObject("FPSPlayer", "Player") |
---|
4 | |
---|
5 | dy = 0 |
---|
6 | randTime = 0 |
---|
7 | eventFinished = false |
---|
8 | randinit = false |
---|
9 | |
---|
10 | function RandTime() |
---|
11 | |
---|
12 | if not randinit then |
---|
13 | math.randomseed(os.clock()) |
---|
14 | randinit = true |
---|
15 | randTime = 8 * math.random() |
---|
16 | end |
---|
17 | end |
---|
18 | |
---|
19 | |
---|
20 | function fallDown(timestep) |
---|
21 | dy = dy + timestep*0.1 |
---|
22 | thisX = fallingguy:getAbsCoorX() |
---|
23 | thisY = fallingguy:getAbsCoorY() |
---|
24 | thisZ = fallingguy:getAbsCoorZ() |
---|
25 | |
---|
26 | fallingguy:setAbsCoor(thisX, thisY - dy, thisZ) |
---|
27 | |
---|
28 | if thisY < -100 then |
---|
29 | eventFinished = true |
---|
30 | end |
---|
31 | |
---|
32 | end |
---|
33 | |
---|
34 | |
---|
35 | function tick(timestep) |
---|
36 | |
---|
37 | RandTime() |
---|
38 | |
---|
39 | if randTime > 0 then |
---|
40 | randTime = randTime - timestep |
---|
41 | else |
---|
42 | fallDown(timestep) |
---|
43 | end |
---|
44 | |
---|
45 | return eventFinished |
---|
46 | |
---|
47 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.