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
243
244
245
246
247
248
249
250
251
252
253
254
255
|
' Hardwire
'
' Copyright 2005 Ian Cowburn
'
' $Id$
'
Strict
Import noddybox.bitmapfont
Import noddybox.keysyms
Import noddybox.gfxmenu
Import "types.bmx"
Import "gametypes.bmx"
Import "game.bmx"
Import "particle.bmx"
Rem
TWire.Init()
For Local t:Int=TWire.CROSS To TWire.BOTTOM_RIGHT
Local w:TWire=TWire.Create(t)
For Local d:Int=TWire.DIR_NONE To TWire.DIR_LEFT
Print TWire.typename[t] + ": " + TWire.dirname[d] + " -> " + TWire.dirname[w.Traverse(d)]
Next
Next
End
EndRem
' ===================================
' 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
' ===================================
'
GameGFX.Init()
Lookup.Init()
GameConfig.Load()
TWire.Init()
Particles.Init()
Sound.Init()
Global bdrop:TMenuBdrop=New TMenuBdrop
Global quit:Int=False
' ===================================
' Main
' ===================================
'
Menu()
While Not quit
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()
Const MENU_PLAY:Int=1
Const MENU_QUIT:Int=2
Const MENU_SCORES:Int=3
Const MENU_KEYS:Int=4
Const MENU_LEFT:Int=5
Const MENU_RIGHT:Int=6
Local done:Int=False
Local menu:TGfxMenu=TGfxMenu.Create(200,0,0,255,255,255,25,bdrop,1)
Local sel:Int
Local defkey:Int=0
Local x1:Int=GraphicsWidth()/3-ImageWidth(GameGFX.play_button)/2
Local x2:Int=GraphicsWidth()/3*2-ImageWidth(GameGFX.play_button)/2
menu.Add(x1,150,GameGFX.play_button,MENU_PLAY)
menu.Add(x2,150,GameGFX.scores_button,MENU_SCORES)
menu.Add(x1,250,GameGFX.keys_button,MENU_KEYS)
menu.Add(x2,250,GameGFX.quit_button,MENU_QUIT)
menu.Add(x1,350,GameGFX.left_button,MENU_LEFT)
menu.Add(x2+ImageWidth(GameGFX.play_button)-ImageWidth(GameGFX.right_button),350,GameGFX.right_button,MENU_RIGHT)
Local tx1:Int=(GraphicsWidth()-GameGFX.large.TextWidth("START LEVEL 1"))/2
Local tx2:Int=tx1+GameGFX.large.TextWidth("START LEVEL ")
Local gm:TGameMap=New TGameMap
While Not done
If gm.overflow
SetClsColor(128,0,0)
Else
SetClsColor(0,0,0)
EndIf
Cls
DrawImage(GameGFX.title,0,0)
gm.Draw()
Particles.Draw()
sel=menu.Render(defkey>0)
If defkey>0
If defkey=7
GameGFX.large.Centre("PRESS A KEY TO GO BACK TO THE MENU",150)
Else
GameGFX.large.Centre("DEFINE KEYS",150)
GameGFX.large.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)
Local c4:Int=128+128*(defkey=4)
Local c5:Int=128+128*(defkey=5)
Local c6:Int=128+128*(defkey=6)
GameGFX.large.DrawColoured("Left",250,180,c1,c1,0)
GameGFX.large.DrawColoured("Right",250,210,c2,c2,0)
GameGFX.large.DrawColoured("Up",250,240,c3,c3,0)
GameGFX.large.DrawColoured("Down",250,270,c4,c4,0)
GameGFX.large.DrawColoured("Rotate",250,300,c5,c5,0)
GameGFX.large.DrawColoured("Pause",250,330,c6,c6,0)
GameGFX.large.DrawColoured(KeySym(GameConfig.kleft),500,180,c1,c1,0)
GameGFX.large.DrawColoured(KeySym(GameConfig.kright),500,210,c2,c2,0)
GameGFX.large.DrawColoured(KeySym(GameConfig.kup),500,240,c3,c3,0)
GameGFX.large.DrawColoured(KeySym(GameConfig.kdown),500,270,c4,c4,0)
GameGFX.large.DrawColoured(KeySym(GameConfig.krot),500,300,c5,c5,0)
GameGFX.large.DrawColoured(KeySym(GameConfig.kpause),500,330,c6,c6,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.kup=k
Case 4
GameConfig.kdown=k
Case 5
GameConfig.krot=k
Case 6
GameConfig.kpause=k
End Select
defkey:+1
If defkey=7
GameConfig.Save()
defkey=0
FlushKeys()
EndIf
EndIf
Else
If KeyHit(KEY_ESCAPE)
done=True
quit=True
EndIf
GameGFX.large.Draw("START LEVEL ",tx1,356)
GameGFX.large.DrawColoured(GameConfig.start_level,tx2,356,255,255,0)
EndIf
Select sel
Case MENU_PLAY
done=True
FlushKeys()
Case MENU_SCORES
gm.AddRow()
FlushKeys()
Case MENU_KEYS
FlushKeys()
defkey=1
Case MENU_QUIT
done=True
quit=True
Case MENU_LEFT
GameConfig.start_level=Max(1,GameConfig.start_level-1)
GameConfig.Save()
Case MENU_RIGHT
GameConfig.start_level=Min(10,GameConfig.start_level+1)
GameConfig.Save()
End Select
Rem
SetScale(2,2)
GameGFX.font.CentreColoured("HARDWIRE",0,255,255,0)
SetScale(1,1)
GameGFX.font.CentreColoured("Copyright (c) 2005 Ian C",20,255,0,0)
EndRem
SetColor(255,255,255)
DrawImage(GameGFX.pointer,MouseX(),MouseY())
Flip
Wend
End Function
|