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
|
' Vectoroids
'
' Copyright 2005 Ian Cowburn
'
' $Id$
'
Strict
Import noddybox.vector
Import noddybox.bitmapfont
Import noddybox.keysyms
Import "types.bmx"
Import "game.bmx"
Import "sounds.bmx"
Import "hiscore.bmx"
' Initialise
'
SeedRnd(MilliSecs())
?Win32
If Switch("--directx")
SetGraphicsDriver D3D7Max2DDriver()
Else
SetGraphicsDriver GLMax2DDriver()
EndIf
?
Graphics 800,600,32,60
HideMouse
SetBlend(ALPHABLEND)
SetAlpha(1.0)
' Globals
'
Lookup.Init()
GameGFX.Init()
TParticleMachine.Init()
GameConfig.Load()
Sounds.Init()
Global quit:Int=False
Global hiscore:THiscore=THiscore.Load()
' Main code
'
Menu()
While Not quit
Local game:TGame=New TGame
While game.Play()
Wend
Sounds.Clear()
TParticleMachine.Clear()
hiscore.Check(game.score)
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()
FlushKeys()
Local done:Int=False
Local defkey:Int=0
Local obj:TVectorGfxObject
Select Rand(1,2)
Case 1
obj=GameGFX.large.Clone()
Case 2
obj=GameGFX.ship.Clone()
End Select
obj.scale=5
obj.x=GraphicsWidth()/2
obj.y=GraphicsHeight()/2
While Not done
If KeyHit(KEY_ESCAPE)
done=True
quit=True
EndIf
Cls
obj.ang=(obj.ang+1) Mod 3600
If defkey=0
SetAlpha(0.5)
Else
SetAlpha(0.2)
EndIf
SetColor(255,255,255)
obj.Draw()
SetAlpha(1)
If defkey>0
If defkey=7
GameGFX.font.Centre("PRESS A KEY TO GO BACK TO THE MENU",120)
Else
GameGFX.font.Centre("DEFINE KEYS",120)
EndIf
GameGFX.font.Draw("left",250,150,255,255*(defkey=1),0)
GameGFX.font.Draw("right",250,170,255,255*(defkey=2),0)
GameGFX.font.Draw("thrust",250,190,255,255*(defkey=3),0)
GameGFX.font.Draw("fire",250,210,255,255*(defkey=4),0)
GameGFX.font.Draw("hyperspace",250,230,255,255*(defkey=5),0)
GameGFX.font.Draw("pause",250,250,255,255*(defkey=6),0)
GameGFX.font.Draw(KeySym(GameConfig.kleft).ToLower(),500,150,255,255*(defkey=1),0)
GameGFX.font.Draw(KeySym(GameConfig.kright).ToLower(),500,170,255,255*(defkey=2),0)
GameGFX.font.Draw(KeySym(GameConfig.kthrust).ToLower(),500,190,255,255*(defkey=3),0)
GameGFX.font.Draw(KeySym(GameConfig.kfire).ToLower(),500,210,255,255*(defkey=4),0)
GameGFX.font.Draw(KeySym(GameConfig.khyper).ToLower(),500,230,255,255*(defkey=5),0)
GameGFX.font.Draw(KeySym(GameConfig.kpause).ToLower(),500,250,255,255*(defkey=6),0)
Local k:Int=0
For Local f:Int=1 To 255
If KeyHit(f)
k=f
Continue
EndIf
Next
If k<>0
Select defkey
Case 1
GameConfig.kleft=k
Case 2
GameConfig.kright=k
Case 3
GameConfig.kthrust=k
Case 4
GameConfig.kfire=k
Case 5
GameConfig.khyper=k
Case 6
GameConfig.kpause=k
End Select
defkey:+1
If defkey=8
GameConfig.Save()
defkey=0
EndIf
EndIf
Else
GameGFX.font.Centre("vectoroids",0,255,255,0)
GameGFX.font.Centre("COPYRIGHT | 2005 IAN C",20,255,0,0)
GameGFX.font.Centre("press space to play",150)
GameGFX.font.Centre("press r to redefine keys",190)
GameGFX.font.Centre("EXTRA LIFE AT 10000 PTS THEN EVERY 50000 PTS",520)
GameGFX.font.Centre("ESCAPE TO QUIT",560)
GameGFX.font.Centre("BASED ON ASTEROIDS | 1979 ~~ ATARI INC.",580,255,0,0)
hiscore.Display(400)
If KeyHit(KEY_ESCAPE)
done=True
quit=True
EndIf
If KeyHit(KEY_R)
FlushKeys()
defkey=1
EndIf
If KeyHit(KEY_SPACE)
FlushKeys()
done=True
EndIf
EndIf
Flip
Wend
End Function
|