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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
'
' Main code for NutterShoot
'
' $Id$
'
Strict
Import noddybox.bitmapfont
Import noddybox.vector
' Includes
'
Import "font_fade.bmx"
Import "menu.bmx"
Import "sprite.bmx"
Import "players.bmx"
' Included binaries
'
Incbin "GFX/font.bmf"
Incbin "GFX/font_shadow.bmf"
Incbin "GFX/earth.png"
Incbin "GFX/layer1.png"
Incbin "GFX/layer2.png"
Incbin "GFX/button.png"
Incbin "GFX/PNG/PLAYER.png"
Incbin "GFX/PNG/PLAYERHAPPY.png"
Incbin "GFX/PNG/PLAYERDEAD.png"
Incbin "GFX/PNG/MOUSE.png"
Incbin "GFX/PNG/BULLET.png"
' Initialise graphics
'
SetGraphicsDriver GLMax2DDriver()
Graphics 800,600,32,60
HideMouse
SetBlend(ALPHABLEND)
' Consts
'
Const SPEED:Float=0.1
Const MAX_SPEED:Float=2.0
' Globals
'
Global quit:Int=False
Global music:Int=True
Global sfx:Int=True
' Global images
'
Global font:TBitmapFont=TBitmapFont.Load("incbin::GFX/font.bmf",0)
Global font_shadow:TBitmapFont=TBitmapFont.Load("incbin::GFX/font_shadow.bmf",0)
Global fade:TFontFade=TFontFade.Create(font)
Global fade_shadow:TFontFade=TFontFade.Create(font_shadow)
Global layer1:TImage=LoadImage("incbin::GFX/layer1.png",FILTEREDIMAGE)
Global layer2:TImage=LoadImage("incbin::GFX/layer2.png",FILTEREDIMAGE)
Global buttonimg:TImage=LoadImage("incbin::GFX/button.png",0)
AutoMidHandle True
Global earthimg:TImage=LoadImage("incbin::GFX/earth.png",0)
AutoMidHandle False
' Load sprites
'
AutoMidHandle True
Global mouse_cursor:TImage=LoadAnimImage("incbin::GFX/PNG/MOUSE.png",16,16,0,3,0)
Global player_image:TImage=LoadAnimImage("incbin::GFX/PNG/PLAYER.png",16,16,0,2,0)
Global bullet_image:TImage=LoadAnimImage("incbin::GFX/PNG/BULLET.png",8,8,0,2,0)
AutoMidHandle False
Global bdropx#=0
Global bdropy#=0
Global mouse:TSprite=TSprite.Create(mouse_cursor,5,True,False,0)
Global actor:TPlayer=TPlayer.Create(player_image,bullet_image,3,False,True,1)
' ----------------------------------------------
' MAIN
' ----------------------------------------------
'
MainMenu()
While Not quit
MainMenu()
Wend
EndGraphics
End
' ----------------------------------------------
' UTILS
' ----------------------------------------------
'
Function StartPage(bground:Int=False,dx:Float=0,dy:Float=0)
Cls
If bground
bdropx:+dx
bdropy:+dy
TileImage(layer2,bdropx/2,bdropy/2)
TileImage(layer1,bdropx,bdropy)
EndIf
End Function
Function EndPage(flush:Int=True)
SetTransform(0,1,1)
mouse.x=MouseX()
mouse.y=MouseY()
mouse.Update()
'If flush Then FlushMem
Flip
End Function
' ----------------------------------------------
' PLAYER CODE
' ----------------------------------------------
'
Function InitPlayer()
actor.sprite.ChangeImage(player_image,1)
actor.NewGame()
End Function
Function MovePlayer()
If KeyDown(KEY_DOWN)
actor.sprite.v.y:+SPEED
ElseIf KeyDown(KEY_UP)
actor.sprite.v.y:-SPEED
ElseIf (actor.sprite.v.y<>0)
If (Abs(actor.sprite.v.y)>SPEED)
actor.sprite.v.y:-Sgn(actor.sprite.v.y)*SPEED
Else
actor.sprite.v.y=0
EndIf
EndIf
If KeyDown(KEY_RIGHT)
actor.sprite.v.x:+SPEED
ElseIf KeyDown(KEY_LEFT)
actor.sprite.v.x:-SPEED
ElseIf (actor.sprite.v.x<>0)
If (Abs(actor.sprite.v.x)>SPEED)
actor.sprite.v.x:-Sgn(actor.sprite.v.x)*SPEED
Else
actor.sprite.v.x=0
EndIf
EndIf
actor.sprite.v.y=Min(MAX_SPEED,Max(actor.sprite.v.y,-MAX_SPEED))
actor.sprite.v.x=Min(MAX_SPEED,Max(actor.sprite.v.x,-MAX_SPEED))
actor.AddBullet(MouseX(),MouseY())
End Function
' ----------------------------------------------
' MENU
' ----------------------------------------------
'
Function MainMenu()
Local a$
Local txt$
Local f:TFontFade=fade_shadow
Local ang:Float=0
Local tx:Int=0
Local done:Int=False
Local menu:TMenu=TMenu.Create(font,buttonimg,100)
menu.Add("PLAY!")
menu.Add("HOW TO PLAY")
menu.Add("EFFECTS ON/OFF")
menu.Add("MUSIC ON/OFF")
menu.Add("QUIT")
RestoreData intro_data
ReadData a$
While a$<>"XXX"
txt:+a$
ReadData a$
Wend
While Not done
StartPage(True,0.2,0.5)'Sin(ang),Cos(ang*2))
SetTransform(0,1,1)
font_shadow.Centre("NUTTER SHOOT",0)
font_shadow.Centre("(C) IAN C 2005",30)
Select menu.Render()
Case "PLAY!"
done=True
Case "HOW TO PLAY"
HowToPlay()
Case "MUSIC ON/OFF"
music=Not music
Case "EFFECTS ON/OFF"
sfx=Not sfx
Case "QUIT"
done=True
quit=True
EndSelect
If KeyDown(KEY_ESCAPE)
done=True
quit=True
EndIf
ang:+0.5
SetTransform(0,2,2)
If music
font.Draw("a",0,0)
Else
font.Draw("b",0,0)
EndIf
If sfx
font.Draw("c",40,0)
Else
font.Draw("d",40,0)
EndIf
SetTransform(0,2,2)
font_shadow.Draw(txt$,tx,550,255,255,100)
tx:-3
If tx<-font.TextWidth(txt[0..1])
tx:+font.TextWidth(txt[0..1])
txt=txt[1..]+txt[0..1]
EndIf
EndPage()
Wend
SetTransform(0,1,1)
End Function
Function HowToPlay()
Local txt$
Local col:Int
Local f:TFontFade=fade_shadow
Local done:Int=False
Local y:Int
Local menu:TMenu=TMenu.Create(font,buttonimg,530)
SetTransform(0,1,1)
InitPlayer()
actor.sprite.y=80
f.Clear()
menu.Add("BACK")
While Not done
StartPage()
MovePlayer()
actor.Update()
If f.IsEmpty()
RestoreData tutor_data
ReadData txt$
y=100
While txt$<>"XXX"
ReadData col
f.Centre(txt$,y,col,0.02,0.02)
ReadData txt$
y:+20
Wend
EndIf
f.Process()
Select menu.Render()
Case "BACK"
done=True
EndSelect
If KeyDown(KEY_ESCAPE)
done=True
quit=True
EndIf
EndPage()
Wend
f.Clear()
End Function
' PROGRAM DATA
'
#intro_data
DefData " "
DefData " "
DefData "SAVE THE EARTH FROM "
DefData "THE PERIL OF BADLY DRAWN SPRITES "
DefData "AFTER THE BLOOD OF THEIR FORMER MASTERS..."
DefData " "
DefData "DEVELOPED WITH BLITZMAX"
DefData " "
DefData "XXX"
#tutor_data
DefData "THIS LITTLE SPRITE IS YOU...",$ff0000
DefData "IT RUNS AROUND WHEN YOU PRESS THE CURSOR KEYS",$ff0000
DefData "AIM WITH THE MOUSE",$ff0000
DefData " ",$ff0000
DefData "TRY IT NOW!",$ffff00
DefData " ",$ff0000
DefData "SHOOT THINGS. DON'T RUN INTO THINGS.",$ff0000
DefData "DON'T GET SHOT. DON'T FORGET TO FLOSS.",$ff0000
DefData "THESE ARE THE RULES!",$ffff00
DefData " ",$ff0000
DefData "XXX"
|