Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/scripts/spaceship_flight.lua @ 4270

Last change on this file since 4270 was 4217, checked in by bensch, 18 years ago

2d-mode again

File size: 1.7 KB
Line 
1-- Create the trigger
2trigger = ScriptTrigger()
3trigger:setName("spaceship_flight_trigger")
4trigger:setScript("spaceship_flight.lua")
5trigger:setFunction("tick")
6trigger:setAbsCoor(2500, 0, -1695)
7trigger:setTarget("SPACE_CRAFT")
8trigger:setRadius(150)
9
10-- Add Objects
11thisscript:addObject("GameWorld", "Ambush_at_Uranus")
12thisscript:addObject("Spacecraft2D", "SPACE_CRAFT")
13thisscript:addObject("Gate", "Hypergate")
14thisscript:addObject("SpaceShip", "TerranCruizer")
15-- Global Variables
16horizontalmode = false
17gateReached = false
18terrancriuseratgate = false
19
20
21function dist( x1,x2,x3, y1,y2,y3 )
22return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
23end
24
25
26function observeSpaceCraft()
27SPACE_CRAFTX = SPACE_CRAFT:getAbsCoorX()
28SPACE_CRAFTY = SPACE_CRAFT:getAbsCoorY()
29SPACE_CRAFTZ = SPACE_CRAFT:getAbsCoorZ()
30
31distance = dist(SPACE_CRAFTX,SPACE_CRAFTY,SPACE_CRAFTZ,6053.186035, -2.306574, -1704.989624)
32
33if distance < 100 then
34Hypergate:destroy()
35end
36
37end
38
39function tick(timestep)
40observeSpaceCraft()
41
42if not horizontalmode then
43 Ambush_at_Uranus:setPlaymode("Horizontal")
44 Ambush_at_Uranus:setSoundtrack("sound/music/00-luke_grey_-_hypermode.ogg")
45 SPACE_CRAFT:setAirFriction(3.0)
46 horizontalmode = true
47end
48
49if not terrancriuseratgate then
50dx = 70 * timestep
51dy = 0 * timestep
52dz = 0 * timestep
53
54TerranCruizerX = TerranCruizer:getAbsCoorX()
55TerranCruizerY = TerranCruizer:getAbsCoorY()
56TerranCruizerZ = TerranCruizer:getAbsCoorZ()
57
58distance = dist(TerranCruizerX,TerranCruizerY,TerranCruizerZ,6053.186035, -2.306574, -1704.989624)
59
60if distance < 100  then
61TerranCruizer:hide()
62dx = 5000
63terrancriuseratgate = true
64end
65
66TerranCruizer:setAbsCoor(TerranCruizerX + dx, TerranCruizerY + dy, TerranCruizerZ + dz)
67
68end
69
70 return false
71end
Note: See TracBrowser for help on using the repository browser.