summaryrefslogtreecommitdiff
path: root/missile_lock.bmx
blob: f4a46521aa57cfb079441e7fd3359a9364df687a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
' Missile Lock
'
' Copyright (C) 2006  Ian Cowburn (ianc@noddybox.co.uk)
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'
' -------------------------------------------------------------------------
'
' $Id$
'
Strict
Framework brl.basic
Import brl.max2d
Import brl.glmax2d
?Win32
Import brl.d3d7max2d
?

Import noddybox.bitmapfont
Import noddybox.keysyms

Import "global.bmx"
Import "gametypes.bmx"
'Import "game.bmx"
Import "particle.bmx"
'Import "help.bmx"

' ===================================
' Initialise
' ===================================
'
SeedRnd(MilliSecs())

?Win32
If Switch("--directx")
	SetGraphicsDriver D3D7Max2DDriver()
Else
	SetGraphicsDriver GLMax2DDriver()
EndIf
?

Graphics 800,600,32,HERTZ
HideMouse

SetBlend(ALPHABLEND)
SetAlpha(1.0)


' ===================================
' Globals
' ===================================
'
GFX.Init()	' MUST be first

Lookup.Init()
GameConfig.Load()
Scroller.Init()
Particles.Init()
Backdrop.Init()
Trail.Init()

Global quit:Int=False


' ===================================
' Main
' ===================================
'
Menu()

While Not quit
	GameState.Reset()
	
	While Not KeyHit(KEY_ESCAPE)
		Cls
		Backdrop.Draw()
		Particles.Draw()
		Trail.Draw()
		GameState.Display()
		GameState.Control()
		GameState.Move()
		SetRotation(GameState.ang)
		DrawImage(GFX.ship,GameState.x,GameState.y)
		SetRotation(0)
		Flip(1)
	Wend
	
	GameConfig.Save()
	
	TFadeScreen.DoFadeOut()
	
	Menu()
Wend

EndGraphics
End


' ===================================
' Argument Routines
' ===================================
'
Function Switch:Int(s:String)
	For Local a:String=EachIn AppArgs
		If a=s
			Return True
		EndIf
	Next
	
	Return False
End Function


' ===================================
' Menu Routines
' ===================================
'
Function Menu()
	Local fade:TFadeScreen=TFadeScreen.FadeIn()
	Local done:Int=False
	Local defkey:Int=0
	
	Particles.Clear()
	GameState.Reset()
	
	While Not done
		Cls

		If Rand(100)>30
			Particles.AddScaledImage(GFX.exhaust,Rand(0,800),Rand(0,600),0.3)
		End If
		
		Backdrop.Draw()
		Particles.Draw()
		GameState.Display()
		Scroller.Draw()
			
		SetColor(255,255,255)
		DrawImage(GFX.title,0,0)
		
		If defkey>0
		
			If defkey=4
				GFX.font.Centre("PRESS A KEY TO GO BACK TO THE MENU",380)
			Else
				GFX.font.Centre("DEFINE KEYS",350)
				GFX.font.Centre("PRESS ESCAPE TO CANCEL",380)
			EndIf
			
			Local c1:Int=128+128*(defkey=1)
			Local c2:Int=128+128*(defkey=2)
			Local c3:Int=128+128*(defkey=3)

			GFX.font.Draw("LEFT",250,200,c1,c1,c1)
			GFX.font.Draw("RIGHT",250,220,c2,c2,c2)
			GFX.font.Draw("PAUSE",250,240,c3,c3,c3)
			GFX.font.Draw(KeySym(GameConfig.kleft),500,200,c1,c1,0)
			GFX.font.Draw(KeySym(GameConfig.kright),500,220,c2,c2,0)
			GFX.font.Draw(KeySym(GameConfig.kpause),500,240,c3,c3,0)

			Local k:Int=-1
			
			For Local f:Int=0 To 255
				If KeyHit(f)
					k=f
					Continue
				EndIf
			Next
			
			If k=KEY_ESCAPE
				GameConfig.Load()
				defkey=0
				FlushKeys()
			ElseIf k<>-1
				Select defkey
					Case 1
						GameConfig.kleft=k
					Case 2
						GameConfig.kright=k
					Case 3
						GameConfig.kpause=k
				End Select
				
				defkey:+1
				
				If defkey=5
					GameConfig.Save()
					defkey=0
					FlushKeys()
				EndIf
			EndIf
		Else
			If KeyHit(KEY_ESCAPE)
				done=True
				quit=True
			EndIf
			
			If KeyHit(KEY_SPACE)
				done=True
			EndIf
			
			If KeyHit(KEY_R)
				defkey=1
				FlushKeys()
			EndIf
			
			GFX.font.Centre("COPYRIGHT (C) NODDYBOX 2006",200)
			
			GFX.font.Centre("PRESS SPACE TO PLAY",300)

			GFX.font.Centre("PRESS R TO REDEFINE KEYS",380)
			GFX.font.Centre("PRESS ESCAPE TO QUIT",400)
		EndIf

		If fade
			If fade.Fade()
				fade.Draw()
			Else
				fade=Null
			EndIf
		EndIf
		
		Flip(1)
	Wend
	
	Particles.Clear()
	TFadeScreen.DoFadeOut()
End Function