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