From 5a8cc026cb6fc591795b8b8e0abec245771889bb Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 12 Oct 2007 23:01:07 +0000 Subject: Updates --- main.bmx | 340 ++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 252 insertions(+), 88 deletions(-) (limited to 'main.bmx') diff --git a/main.bmx b/main.bmx index f360e90..4b91516 100644 --- a/main.bmx +++ b/main.bmx @@ -6,95 +6,240 @@ Strict Import noddybox.bitmapfont +Import noddybox.vector ' Includes ' -Include "font_fade.bmx" +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/backdrop.bmp" +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 font:BitmapFont=BitmapFont.Load("incbin::GFX/font.bmf",0) -Global font_shadow:BitmapFont=BitmapFont.Load("incbin::GFX/font_shadow.bmf",0) -Global quit:Int=True -Global fade:FontFade=FontFade.Create(font) -Global fade_shadow:FontFade=FontFade.Create(font_shadow) -Global bdrop:TImage=LoadImage("incbin::GFX/backdrop.bmp",0) +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 -SetImageHandle(bdrop,400,300) +' 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 -Intro() +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 -Function StartPage(bground:Int=True,sx:Float=1,sy:Float=1) +' ---------------------------------------------- +' UTILS +' ---------------------------------------------- +' +Function StartPage(bground:Int=False,dx:Float=0,dy:Float=0) Cls If bground - Local x:Float,y:Float,r:Float,a:Float - a=GetAlpha() - r=GetRotation() - GetScale(x,y) - - SetAlpha(2) - SetTransform(0,sx,sy) - DrawImage(bdrop,400,300) - SetAlpha(a) - SetTransform(r,x,y) + bdropx:+dx + bdropy:+dy + TileImage(layer2,bdropx/2,bdropy/2) + TileImage(layer1,bdropx,bdropy) EndIf End Function Function EndPage(flush:Int=True) - If flush Then FlushMem + SetTransform(0,1,1) + mouse.x=MouseX() + mouse.y=MouseY() + mouse.Update() + 'If flush Then FlushMem Flip End Function -Function Intro() - Local c=20 +' ---------------------------------------------- +' 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 f:FontFade=fade_shadow + 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) - SetTransform(0,2,2) + menu.Add("PLAY!") + menu.Add("HOW TO PLAY") + menu.Add("EFFECTS ON/OFF") + menu.Add("MUSIC ON/OFF") + menu.Add("QUIT") RestoreData intro_data - While Not KeyHit(KEY_SPACE) - StartPage() + ReadData a$ + + While a$<>"XXX" + txt:+a$ + ReadData a$ + Wend + + While Not done + StartPage(True,0.2,0.5)'Sin(ang),Cos(ang*2)) - c:-1 + SetTransform(0,1,1) - If c=0 - c=20 - - ReadData a$ - - If a$="XXX" - RestoreData intro_data - c=200 - Else - f.Centre(a$,500,$ffff80,0,0.008,-2) - EndIf + 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 - f.Process() + 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 @@ -102,66 +247,85 @@ Function Intro() End Function -Function MainMenu() -End Function - - -Rem -sc=10 -t$="THIS IS SOME VERY, VERY, *VERY* ~~LARGE SCROLLING TEXT....." -x#=0 -ang#=0 -angi#=0.2 - -While Not KeyHit(KEY_ESCAPE) - Cls - - For f=0 Until NO - st[f].Update() - Next +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(ang,sc,sc) + SetTransform(0,1,1) + InitPlayer() - ang:+angi + actor.sprite.y=80 + + f.Clear() - If ang<=-10 Or ang>=10 Then angi=-angi - - fnt.DrawColoured(t$,x,0,255,255,255)'128,128) + menu.Add("BACK") - If Not KeyDown(KEY_P) - x:-5 + While Not done + StartPage() + + MovePlayer() - If x<-fnt.TextWidth(t[0..1]) - x:+fnt.TextWidth(t[0..1]) - t=t[1..]+t[0..1] + 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 - EndIf - FlushMem - - Flip + f.Process() + + Select menu.Render() + Case "BACK" + done=True + EndSelect + + If KeyDown(KEY_ESCAPE) + done=True + quit=True + EndIf + + EndPage() + Wend -Wend + f.Clear() +End Function -End Rem ' PROGRAM DATA ' #intro_data - DefData "NUTTER SHOOT" - DefData " " - DefData "(C) IAN C 2005" - DefData " " - DefData "THIS IS FREE SOFTWARE." - DefData "SEE THE GNU GENERAL" - DefData "PUBLIC LICENSE FOR" - DefData "DETAILS." - DefData " " - DefData " " - DefData "PRESS SPACE TO PLAY" - DefData " " - DefData " " + 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 "HTTP://WWW.BLITZBASIC.COM" + 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" -- cgit v1.2.3