source:
data/trunk/scripts/falldown.lua
@
4028
Last change on this file since 4028 was 3991, checked in by bensch, 19 years ago | |
---|---|
File size: 580 bytes |
Rev | Line | |
---|---|---|
[3966] | 1 | dy = 0 |
[3927] | 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 | |
[3945] | 11 | randTime = 10 * math.random() |
[3927] | 12 | end |
13 | end | |
14 | ||
15 | ||
16 | function fallDown(timestep) | |
[3966] | 17 | dy = dy + timestep*0.01 |
18 | thisX = fallingguy:getAbsCoorX() | |
19 | thisY = fallingguy:getAbsCoorY() | |
20 | thisZ = fallingguy:getAbsCoorZ() | |
[3927] | 21 | |
[3966] | 22 | fallingguy:setAbsCoor(thisX, thisY - dy, thisZ) |
23 | ||
24 | if thisY < 0 then | |
[3927] | 25 | eventFinished = true |
26 | end | |
27 | ||
[3966] | 28 | end |
[3927] | 29 | |
[3966] | 30 | |
[3927] | 31 | function tick(timestep) |
[3945] | 32 | |
[3927] | 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.