source:
data/branches/single_player_map/scripts/falldown.lua
@
4068
Last change on this file since 4068 was 4066, checked in by snellen, 18 years ago | |
---|---|
File size: 699 bytes |
Rev | Line | |
---|---|---|
[4051] | 1 | -- Get objects from orxonox |
2 | thisscript:addObject("TestEntity", "fallingguy") | |
3 | thisscript:addObject("FPSPlayer", "Player") | |
4 | ||
[3966] | 5 | dy = 0 |
[3927] | 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 | |
[4056] | 15 | randTime = 8 * math.random() |
[3927] | 16 | end |
17 | end | |
18 | ||
19 | ||
20 | function fallDown(timestep) | |
[4066] | 21 | dy = dy + timestep |
[3966] | 22 | thisX = fallingguy:getAbsCoorX() |
23 | thisY = fallingguy:getAbsCoorY() | |
24 | thisZ = fallingguy:getAbsCoorZ() | |
[3927] | 25 | |
[3966] | 26 | fallingguy:setAbsCoor(thisX, thisY - dy, thisZ) |
27 | ||
[4056] | 28 | if thisY < -100 then |
[3927] | 29 | eventFinished = true |
30 | end | |
31 | ||
[3966] | 32 | end |
[3927] | 33 | |
[3966] | 34 | |
[3927] | 35 | function tick(timestep) |
[3945] | 36 | |
[3927] | 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.