' ' 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"