share/hedgewars/Data/Scripts/Multiplayer/Tumbler.lua
author mikade
Mon, 24 Jan 2011 23:48:44 +0200
changeset 4872 6b2fb9f0054a
child 5325 261b79ba22b1
permissions -rw-r--r--
Two new gameplay modes: Tumbler and Racer. Knock hedgehogs with Tumber. Race against your friends with Racer. Both modes could still use more development.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4872
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     1
-- enable awesome translaction support so we can use loc() wherever we want
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     2
loadfile(GetDataPath() .. "Scripts/Locale.lua")()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     3
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     4
local moveTimer = 0
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     5
local leftOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     6
local rightOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     7
local upOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     8
local downOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
     9
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    10
local shotsMax = 10
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    11
local shotsLeft = 50
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    12
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    13
local TimeLeftCounter = 0
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    14
local TimeLeft = 30--000
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    15
local stopMovement = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    16
local tumbleStarted = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    17
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    18
------------------------
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    19
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    20
function GetSpeed()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    21
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    22
	dx, dy = GetGearVelocity(CurrentHedgehog)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    23
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    24
	x = dx*dx
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    25
	y = dy*dy
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    26
	z = x+y
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    27
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    28
	z = z*100
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    29
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    30
	k = z%1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    31
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    32
	if k ~= 0 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    33
	 z = z - k
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    34
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    35
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    36
	return(z)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    37
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    38
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    39
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    40
function onGameInit()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    41
	--Theme = "Hell"
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    42
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    43
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    44
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    45
function onGameStart()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    46
	ShowMission(loc("TUMBLER"), "a Hedgewars mini-game", "- Use the arrow keys to move|- Use [enter] and [backspace] to fire", 4, 4000)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    47
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    48
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    49
function onHJump()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    50
	if (shotsLeft > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then -- seems to not work with a hedgehog nil chek
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    51
		shotsLeft = shotsLeft - 1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    52
		AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtMortar, 0, 0, 0, 1)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    53
		AddCaption(loc("Shots Left: ") .. shotsLeft)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    54
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    55
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    56
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    57
function onLJump()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    58
	if (shotsLeft > 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then -- seems to not work with a hedgehog nil chek
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    59
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    60
		dx, dy = GetGearVelocity(CurrentHedgehog)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    61
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    62
		--boosts in the direction you're already going
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    63
		--[[if dx >= 0 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    64
			x = -15
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    65
		elseif dx < 0 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    66
			x = 15
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    67
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    68
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    69
		if dy >= 0 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    70
			y = -15
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    71
		elseif dy < 0 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    72
			y = 15
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    73
		end]]
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    74
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    75
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    76
		-- this repositions where the explosions are going to appear
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    77
		-- based on the users INTENDED (keypress) direction
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    78
		-- thus allowing to boost yourself or change direction with
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    79
		-- a blast
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    80
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    81
		-- naturally, it's also an anti-hog weapon
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    82
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    83
		x = 0
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    84
		y = 0
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    85
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    86
		if leftOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    87
			x = x + 15
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    88
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    89
		if rightOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    90
			x = x - 15
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    91
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    92
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    93
		if upOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    94
			y = y + 15
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    95
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    96
		if downOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    97
			y = y - 15
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    98
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
    99
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   100
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   101
		shotsLeft = shotsLeft - 1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   102
		AddGear((GetX(CurrentHedgehog) + x), (GetY(CurrentHedgehog) + y), gtGrenade, 0, 0, 0, 1)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   103
		AddCaption(loc("Shots Left: ") .. shotsLeft)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   104
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   105
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   106
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   107
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   108
function onLeft()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   109
	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   110
		leftOn = true
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   111
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   112
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   113
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   114
function onRight()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   115
	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   116
		rightOn = true
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   117
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   118
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   119
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   120
function onUp()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   121
	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   122
		upOn = true
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   123
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   124
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   125
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   126
function onDown()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   127
	if (CurrentHedgehog ~= nil) and (stopMovement == false) then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   128
		downOn = true
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   129
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   130
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   131
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   132
function onDownUp()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   133
	downOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   134
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   135
function onUpUp()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   136
	upOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   137
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   138
function onLeftUp()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   139
	leftOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   140
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   141
function onRightUp()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   142
	rightOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   143
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   144
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   145
function onNewTurn()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   146
	shotsLeft = shotsMax
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   147
	stopMovement = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   148
	tumbleStarted = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   149
	--SetInputMask(band(0xFFFFFFFF, bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmPrecise+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon)))
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   150
	--AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   151
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   152
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   153
function onGameTick()
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   154
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   155
	-- start the player tumbling with a boom once their turn has actually begun
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   156
	if tumbleStarted == false then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   157
		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   158
			AddCaption("Good to go!")
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   159
			tumbleStarted = true
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   160
			TimeLeft = 45
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   161
			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   162
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   163
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   164
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   165
	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   166
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   167
		--AddCaption(loc("Speed: ") .. GetSpeed())
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   168
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   169
		-- Calculate and display turn time
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   170
		TimeLeftCounter = TimeLeftCounter + 1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   171
		if TimeLeftCounter == 1000 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   172
			TimeLeftCounter = 0
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   173
			TimeLeft = TimeLeft - 1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   174
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   175
			if TimeLeft >= 0 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   176
				--TurnTimeLeft = TimeLeft
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   177
				AddCaption(loc("Time Left: ") .. TimeLeft)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   178
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   179
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   180
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   181
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   182
		--if TimeLeft >= 0 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   183
		--	--TurnTimeLeft = TimeLeft
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   184
		--	AddCaption(loc("Time Left: ") .. TimeLeft)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   185
		--end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   186
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   187
		--ShowMission(loc("TUMBLER"), loc("v0.2"), loc("Speed: ") .. GetSpeed() .. "|" .. loc("Ammo: ") .. shotsLeft, 4, 0)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   188
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   189
		if TimeLeft == 0 then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   190
			stopMovement = true
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   191
			upOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   192
			down = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   193
			leftOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   194
			rightOn = false
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   195
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   196
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   197
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   198
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   199
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   200
		-- handle movement based on IO
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   201
		moveTimer = moveTimer + 1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   202
		if moveTimer == 100 then -- 100
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   203
			moveTimer = 0
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   204
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   205
			dx, dy = GetGearVelocity(CurrentHedgehog)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   206
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   207
			dxlimit = 0.4
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   208
			dylimit = 0.4
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   209
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   210
			if dx > dxlimit then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   211
				dx = dxlimit
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   212
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   213
			if dy > dylimit then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   214
				dy = dylimit
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   215
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   216
			if dx < -dxlimit then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   217
				dx = -dxlimit
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   218
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   219
			if dy < -dylimit then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   220
				dy = -dylimit
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   221
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   222
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   223
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   224
			if leftOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   225
				dx = dx - 0.1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   226
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   227
			if rightOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   228
				dx = dx + 0.1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   229
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   230
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   231
			if upOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   232
				dy = dy - 0.1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   233
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   234
			if downOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   235
				dy = dy + 0.1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   236
			end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   237
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   238
			--if leftOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   239
			--	dx = dx - 0.04
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   240
			--end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   241
			--if rightOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   242
			--	dx = dx + 0.04
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   243
			--end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   244
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   245
			--if upOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   246
			--	dy = dy - 0.1
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   247
			--end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   248
			--if downOn == true then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   249
			--	dy = dy + 0.06
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   250
			--end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   251
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   252
			SetGearVelocity(CurrentHedgehog, dx, dy)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   253
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   254
		end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   255
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   256
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   257
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   258
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   259
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   260
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   261
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   262
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   263
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   264
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   265
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   266
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   267
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   268
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   269
function onGearDamage(gear, damage)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   270
	if gear == CurrentHedgehog then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   271
		-- You are now tumbling
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   272
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   273
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   274
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   275
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   276
function onGearAdd(gear)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   277
end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   278
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   279
function onGearDelete(gear)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   280
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   281
	if CurrentHedgehog ~= nil then
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   282
		FollowGear(CurrentHedgehog)
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   283
	end
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   284
6b2fb9f0054a Two new gameplay modes: Tumbler and Racer.
mikade
parents:
diff changeset
   285
end