summaryrefslogtreecommitdiff
path: root/main.bmx
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-10-02 02:08:48 +0000
committerIan C <ianc@noddybox.co.uk>2005-10-02 02:08:48 +0000
commit7ff4818c925a84230b5f5386fd90198f6419044a (patch)
tree89cd6d69782cff39ce8a27cc6d36fa3f9b1e256f /main.bmx
parent2f3aeb2c37136463c73a1df65797d7996b6f6034 (diff)
Added initial Menu code.
Diffstat (limited to 'main.bmx')
-rw-r--r--main.bmx173
1 files changed, 166 insertions, 7 deletions
diff --git a/main.bmx b/main.bmx
index 389bdfd..641adc6 100644
--- a/main.bmx
+++ b/main.bmx
@@ -14,17 +14,26 @@ Import "types.bmx"
Import "level.bmx"
Import "game.bmx"
Import "designer.bmx"
+Import "menu.bmx"
' Included binaries
'
Incbin "GFX/font.bmf"
-Incbin "GFX/gui.bmf"
+Incbin "GFX/small.bmf"
Incbin "GFX/STAR.png"
Incbin "GFX/MASS.png"
Incbin "GFX/POINT.png"
Incbin "GFX/PARTICLE.png"
Incbin "GFX/POINTER.png"
Incbin "GFX/COLLECTOR.png"
+Incbin "GFX/play_button.png"
+Incbin "GFX/edit_button.png"
+Incbin "GFX/load_button.png"
+Incbin "GFX/toy_button.png"
+Incbin "GFX/quit_button.png"
+Incbin "GFX/left_button.png"
+Incbin "GFX/right_button.png"
+Incbin "GFX/scores_button.png"
' Initialise
@@ -40,13 +49,21 @@ SetAlpha(1.0)
' Globals
'
GameGFX.font=TBitmapFont.Load("incbin::GFX/font.bmf",0)
-GameGFX.guifont=TBitmapFont.Load("incbin::GFX/gui.bmf",0)
+GameGFX.smallfont=TBitmapFont.Load("incbin::GFX/small.bmf",0)
GameGFX.star=LoadAnimImage("incbin::GFX/STAR.png",8,8,0,2)
GameGFX.mass=LoadAnimImage("incbin::GFX/MASS.png",8,8,0,2)
GameGFX.collector=LoadAnimImage("incbin::GFX/COLLECTOR.png",8,8,0,2)
-GameGFX.point=LoadImage("incbin::GFX/POINT.png",0)
+GameGFX.point=LoadImage("incbin::GFX/POINT.png",FILTEREDIMAGE)
GameGFX.particle=LoadImage("incbin::GFX/PARTICLE.png",0)
GameGFX.pointer=LoadImage("incbin::GFX/POINTER.png",0)
+GameGFX.play_button=LoadImage("incbin::GFX/play_button.png",0)
+GameGFX.edit_button=LoadImage("incbin::GFX/edit_button.png",0)
+GameGFX.load_button=LoadImage("incbin::GFX/load_button.png",0)
+GameGFX.toy_button=LoadImage("incbin::GFX/toy_button.png",0)
+GameGFX.quit_button=LoadImage("incbin::GFX/quit_button.png",0)
+GameGFX.left_button=LoadImage("incbin::GFX/left_button.png",0)
+GameGFX.right_button=LoadImage("incbin::GFX/right_button.png",0)
+GameGFX.scores_button=LoadImage("incbin::GFX/scores_button.png",0)
SetImageHandle(GameGFX.star,3,3)
SetImageHandle(GameGFX.mass,3,3)
@@ -58,14 +75,156 @@ SetImageHandle(GameGFX.pointer,0,0)
TPoint.img=GameGFX.point
TParticle.img=GameGFX.particle
+TGUIFont.font=GameGFX.font
+
TParticleMachine.Init()
-' Consts
+Global quit:Int=False
+Global levelfile:String="Default.ppinch"
+Global levelset:TLevelSet=Null
+Global selected_level:Int=0
+
+' Initialisation
'
+Try
+ levelset=TLevelSet.Load(levelfile)
+Catch e:TLevelException
+ Error(e.message,True)
+EndTry
+
+If levelset.level.Count()<1
+ Error("Default levelset has no levels!",True)
+EndIf
-' Test code
+
+' Main code
'
-LevelDesigner()
+Menu()
+
+While Not quit
+ Menu()
+Wend
EndGraphics
-End \ No newline at end of file
+End
+
+' ===================================
+' Error Routines
+' ===================================
+'
+Function Error(s:String, fatal:Int=False)
+ Local f:Int=0
+ Local t:Int=0
+ FlushKeys()
+
+ SetScale(3,3)
+
+ While Not KeyHit(KEY_ESCAPE)
+ Cls
+
+ GameGFX.font.CentreColoured(s,GraphicsHeight()/4,255,255*f,255*f)
+
+ If fatal
+ GameGFX.font.CentreColoured("FATAL ERROR",0,255,255,255)
+ GameGFX.font.CentreColoured("Press ESCAPE to exit",GraphicsHeight()/4*3,255,255,255)
+ Else
+ GameGFX.font.CentreColoured("Press ESCAPE",GraphicsHeight()/4*3,255,255,255)
+ EndIf
+
+ t:+1
+
+ If t=30
+ t=0
+ f=1-f
+ EndIf
+
+ Flip
+ Wend
+
+ If fatal
+ EndGraphics
+ End
+ EndIf
+
+ SetScale(1,1)
+End Function
+
+' ===================================
+' Menu Routines
+' ===================================
+'
+Function Menu()
+ Const MENU_PLAY:Int=1
+ Const MENU_EDIT:Int=2
+ Const MENU_LOAD:Int=3
+ Const MENU_TOY:Int=4
+ Const MENU_QUIT:Int=5
+ Const MENU_LEFT:Int=6
+ Const MENU_RIGHT:Int=7
+ Const MENU_SCORES:Int=8
+
+ Local done:Int=False
+ Local menu:TMenu=TMenu.Create()
+ Local sel:Int
+
+ Local x1:Int=(GraphicsWidth()/2-ImageWidth(GameGFX.play_button))/2
+ Local x2:Int=x1+GraphicsWidth()/2
+
+ menu.Add(x1,100,GameGFX.play_button,MENU_PLAY)
+ menu.Add(x2,100,GameGFX.scores_button,MENU_SCORES)
+ menu.Add(x1,200,GameGFX.load_button,MENU_LOAD)
+ menu.Add(x2,200,GameGFX.edit_button,MENU_EDIT)
+ menu.Add(x1,300,GameGFX.toy_button,MENU_TOY)
+ menu.Add(x2,300,GameGFX.quit_button,MENU_QUIT)
+ menu.Add(64,530,GameGFX.left_button,MENU_LEFT)
+ menu.Add(GraphicsWidth()-96,530,GameGFX.right_button,MENU_RIGHT)
+
+ While Not done
+ If KeyHit(KEY_ESCAPE)
+ done=True
+ quit=True
+ EndIf
+
+ Cls
+
+ sel=menu.Render()
+
+ Select sel
+ Case MENU_PLAY
+ done=True
+ Case MENU_LOAD
+ LevelDesigner()
+ FlushKeys()
+ Case MENU_EDIT
+ LevelDesigner()
+ FlushKeys()
+ Case MENU_TOY
+ done=True
+ Case MENU_QUIT
+ done=True
+ quit=True
+ Case MENU_LEFT
+ selected_level:-1
+
+ If selected_level<0
+ selected_level=levelset.level.Count()-1
+ EndIf
+ Case MENU_RIGHT
+ selected_level=(selected_level+1) Mod levelset.level.Count()
+ End Select
+
+ SetScale(2,2)
+ GameGFX.font.CentreColoured("PARTICLE PINCH",0,255,255,0)
+ GameGFX.font.CentreColoured("Start Level",530,255,0,255)
+ GameGFX.font.Centre(levelset.Get(selected_level).name,545)
+
+ SetScale(1,1)
+ GameGFX.font.CentreColoured("Copyright (c) 2005 Ian Cowburn",20,255,0,0)
+
+ SetColor(255,255,255)
+ DrawImage(GameGFX.pointer,MouseX(),MouseY())
+
+ Flip
+ FlushMem
+ Wend
+End Function \ No newline at end of file