summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Default.ppinchbin1243 -> 1740 bytes
-rw-r--r--GFX/button.pngbin3490 -> 0 bytes
-rw-r--r--GFX/button.pspimagebin0 -> 17908 bytes
-rw-r--r--GFX/edit_button.pngbin0 -> 6169 bytes
-rw-r--r--GFX/gui.bmfbin21036 -> 0 bytes
-rw-r--r--GFX/left_button.pngbin0 -> 1082 bytes
-rw-r--r--GFX/load_button.pngbin0 -> 6704 bytes
-rw-r--r--GFX/play_button.pngbin0 -> 6484 bytes
-rw-r--r--GFX/quit_button.pngbin0 -> 6662 bytes
-rw-r--r--GFX/right_button.pngbin0 -> 1049 bytes
-rw-r--r--GFX/scores_button.pngbin0 -> 7943 bytes
-rw-r--r--GFX/small.bmfbin0 -> 10028 bytes
-rw-r--r--GFX/toy_button.pngbin0 -> 5891 bytes
-rw-r--r--designer.bmx4
-rw-r--r--game.bmx64
-rw-r--r--level.bmx11
-rw-r--r--main.bmx173
-rw-r--r--menu.bmx129
-rw-r--r--types.bmx31
19 files changed, 398 insertions, 14 deletions
diff --git a/Default.ppinch b/Default.ppinch
index 7e40481..8cff31f 100644
--- a/Default.ppinch
+++ b/Default.ppinch
Binary files differ
diff --git a/GFX/button.png b/GFX/button.png
deleted file mode 100644
index 6e78c3a..0000000
--- a/GFX/button.png
+++ /dev/null
Binary files differ
diff --git a/GFX/button.pspimage b/GFX/button.pspimage
new file mode 100644
index 0000000..9039782
--- /dev/null
+++ b/GFX/button.pspimage
Binary files differ
diff --git a/GFX/edit_button.png b/GFX/edit_button.png
new file mode 100644
index 0000000..6945de7
--- /dev/null
+++ b/GFX/edit_button.png
Binary files differ
diff --git a/GFX/gui.bmf b/GFX/gui.bmf
deleted file mode 100644
index 364f158..0000000
--- a/GFX/gui.bmf
+++ /dev/null
Binary files differ
diff --git a/GFX/left_button.png b/GFX/left_button.png
new file mode 100644
index 0000000..2d470f1
--- /dev/null
+++ b/GFX/left_button.png
Binary files differ
diff --git a/GFX/load_button.png b/GFX/load_button.png
new file mode 100644
index 0000000..024e753
--- /dev/null
+++ b/GFX/load_button.png
Binary files differ
diff --git a/GFX/play_button.png b/GFX/play_button.png
new file mode 100644
index 0000000..afab315
--- /dev/null
+++ b/GFX/play_button.png
Binary files differ
diff --git a/GFX/quit_button.png b/GFX/quit_button.png
new file mode 100644
index 0000000..34b54c2
--- /dev/null
+++ b/GFX/quit_button.png
Binary files differ
diff --git a/GFX/right_button.png b/GFX/right_button.png
new file mode 100644
index 0000000..4f95c40
--- /dev/null
+++ b/GFX/right_button.png
Binary files differ
diff --git a/GFX/scores_button.png b/GFX/scores_button.png
new file mode 100644
index 0000000..52a8f55
--- /dev/null
+++ b/GFX/scores_button.png
Binary files differ
diff --git a/GFX/small.bmf b/GFX/small.bmf
new file mode 100644
index 0000000..bd4a8a8
--- /dev/null
+++ b/GFX/small.bmf
Binary files differ
diff --git a/GFX/toy_button.png b/GFX/toy_button.png
new file mode 100644
index 0000000..ae6b8f6
--- /dev/null
+++ b/GFX/toy_button.png
Binary files differ
diff --git a/designer.bmx b/designer.bmx
index 9afde62..e5ded2c 100644
--- a/designer.bmx
+++ b/designer.bmx
@@ -58,7 +58,7 @@ Type TDesObj Abstract
End Method
Method DrawCoord(x:Int, y:Int)
- GameGFX.guifont.Draw(x+","+y,0,0)
+ GameGFX.font.Draw(x+","+y,0,0)
End Method
Method DoubleString:String(v:Double)
@@ -432,8 +432,6 @@ Type Designer
obj = CreateList()
- TGUIFont.font = GameGFX.guifont
-
levelset = New TLevelSet
level = New TLevel
levelindex = 0
diff --git a/game.bmx b/game.bmx
index 6c30f84..3556409 100644
--- a/game.bmx
+++ b/game.bmx
@@ -52,9 +52,54 @@ Type TGame
o.coli=5
o.final_percent=0
o.pass_time=0
+
+ TParticleMachine.Clear()
+
Return o
End Function
+ Method LabelMass(m:TMass)
+ Local x:Int=m.x
+ Local y:Int=m.y
+ Local tx:Int
+ Local lx:Int
+ Local ty:Int
+ Local ly:Int
+ Local s:String
+ Local l:Int
+
+ If m.inverse
+ s="-"+Int(m.mass)+" NEWTONS"
+ Else
+ s=Int(m.mass)+" NEWTONS"
+ EndIf
+
+ If m.friend
+ s="COLLECTOR: " + s
+ Else
+ s="MASS: " + s
+ EndIf
+
+ l=GameGFX.smallfont.TextWidth(s)
+
+ ly=y
+ ty=Max(0,Min(GraphicsHeight()-GameGFX.smallfont.MaxHeight(),y-3))
+
+ If x<GraphicsWidth()/2
+ tx=0
+ lx=l+2
+ x:-4
+ Else
+ tx=GraphicsWidth()-GameGFX.smallfont.TextWidth(s)
+ lx=tx-3
+ x:+4
+ EndIf
+
+ SetColor(255,col,col)
+ DrawLine(x,y,lx,ly)
+ GameGFX.smallfont.DrawColoured(s,tx,ty+2,255,col,col)
+ End Method
+
Method Intro()
Local y:Int=GraphicsHeight()/4
Local yi:Int=25
@@ -65,6 +110,10 @@ Type TGame
coli=-coli
EndIf
+ For Local m:TMass=EachIn mass
+ LabelMass(m)
+ Next
+
SetScale(2,2)
GameGFX.font.CentreColoured(level.name,y,col,col,255-col)
@@ -74,9 +123,9 @@ Type TGame
y:+yi
If level.maxmass>1
- GameGFX.font.CentreColoured("You can place only "+level.maxmass+" masses",y,col/2,col,col)
+ GameGFX.font.CentreColoured("You can place only "+level.maxmass+" masses of " + Int(level.placemass) + " Newtons",y,col/2,col,col)
Else
- GameGFX.font.CentreColoured("You can place only 1 mass",y,col/2,col,col)
+ GameGFX.font.CentreColoured("You can place only 1 mass of " + Int(level.placemass) + " Newtons",y,col/2,col,col)
EndIf
y:+yi
@@ -158,6 +207,13 @@ Type TGame
If percent>=level.winpercent And pass_time=0
pass_time=timer
EndIf
+
+ Local lostpercent:Int=Int(Double(lost)/Double(num)*100.0)
+
+ If lostpercent>(101-level.winpercent)
+ done=LEVEL_LOST
+ final_percent=percent
+ EndIf
EndIf
If (timer=0 Or num=captured+lost) And done=LEVEL_NOTOVER
@@ -183,8 +239,9 @@ Type TGame
GameGFX.font.Draw("LEFT",400,0)
SetScale(2,2)
+ SetColor(255,255,255)
For Local f:Int=0 Until level.maxmass-placed
- DrawImage(GameGFX.mass,410+txtoff[3]+f*10,4)
+ DrawImage(GameGFX.mass,410+txtoff[3]+f*10,3)
Next
SetScale(1,1)
@@ -225,6 +282,7 @@ Type TGame
col:+coli
If col=255 Or col=0
+ TParticleMachine.AddFirework(Rand(0,GraphicsWidth()),Rand(0,GraphicsHeight()))
coli=-coli
EndIf
EndIf
diff --git a/level.bmx b/level.bmx
index b86c33a..8535a64 100644
--- a/level.bmx
+++ b/level.bmx
@@ -286,4 +286,15 @@ Type TLevelSet
Return True
End Method
+
+ Method Get:TLevel(i:Int)
+ Local tl:TLink=level.FirstLink()
+
+ While i>0 And tl<>Null
+ i:-1
+ tl=tl.NextLink()
+ Wend
+
+ Return TLevel(tl.Value())
+ End Method
End Type
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
diff --git a/menu.bmx b/menu.bmx
new file mode 100644
index 0000000..f156891
--- /dev/null
+++ b/menu.bmx
@@ -0,0 +1,129 @@
+' Particle Pinch
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+
+Import "types.bmx"
+
+Type TMenu
+ Field list:TList
+ Field bdrop:TList
+ Field mbdown:Int
+
+ Function Create:TMenu()
+ Local menu:TMenu=New TMenu
+
+ menu.list=New TList
+ menu.bdrop=New TList
+ menu.mbdown=False
+
+ For Local f:Int=0 To 500
+ menu.bdrop.AddLast(New TMenuBdrop)
+ Next
+
+ Return menu
+ End Function
+
+ Method Add(x:Int, y:Int, i:TImage, id:Int)
+ list.AddLast(TMenuOpt.Create(x,y,i,id))
+ End Method
+
+ ' Returns the selected item, or -1 for none. Err, so don't use -1 as an ID.
+ '
+ Method Render:Int()
+ Local in:Int=-1
+ Local mx:Int=MouseX()
+ Local my:Int=MouseY()
+ Local any:Int=False
+
+ SetAlpha(0.5)
+ For Local p:TMenuBdrop=EachIn bdrop
+ p.Update()
+ Next
+ SetAlpha(1)
+
+ For Local opt:TMenuOpt=EachIn list
+ If opt.InBox(mx,my)
+ SetColor(255,255,200)
+
+ If KeyDown(KEY_MOUSELEFT)
+ mbdown=True
+ DrawImage(opt.i,opt.x,opt.y+2)
+ any=True
+ Else
+ DrawImage(opt.i,opt.x,opt.y)
+ If mbdown
+ in=opt.id
+ EndIf
+ mbdown=False
+ EndIf
+ Else
+ SetColor(200,200,200)
+ DrawImage(opt.i,opt.x,opt.y)
+ EndIf
+ Next
+
+ If Not any
+ mbdown=False
+ EndIf
+
+
+ Return in
+ End Method
+End Type
+
+Type TMenuOpt
+ Field x:Int
+ Field y:Int
+ Field i:TImage
+ Field id:Int
+
+ Function Create:TMenuOpt(x:Int, y:Int, i:TImage, id:Int)
+ Local o:TMenuOpt=New TMenuOpt
+
+ If x=-1
+ x=(GraphicsWidth()-ImageWidth(i))/2
+ EndIf
+
+ o.x=x
+ o.y=y
+ o.i=i
+ o.id=id
+
+ Return o
+ End Function
+
+ Method InBox:Int(mx:Int, my:Int)
+ Return mx>=x And my>=y And mx<=x+ImageWidth(i) And my<=y+ImageHeight(i)
+ End Method
+End Type
+
+Type TMenuBdrop
+ Field r:Int
+ Field g:Int
+ Field b:Int
+ Field x:Double
+ Field y:Double
+ Field yi:Double
+
+ Method New()
+ r=Rand(128,255)
+ g=Rand(128,255)
+ b=Rand(128,255)
+ x=Rnd(0,GraphicsWidth())
+ y=Rnd(0,GraphicsHeight())
+ yi=Rnd(0.1,3)
+ End Method
+
+ Method Update()
+ SetColor(r,g,b)
+ DrawImage(GameGFX.point,x,y)
+ y:+yi
+ If y>GraphicsHeight()
+ y=0
+ EndIf
+ End Method
+End Type \ No newline at end of file
diff --git a/types.bmx b/types.bmx
index 0c06eba..7fd66ca 100644
--- a/types.bmx
+++ b/types.bmx
@@ -13,13 +13,22 @@ Const MASSRAD:Int=3
Type GameGFX
Global font:TBitmapFont
- Global guifont:TBitmapFont
+ Global smallfont:TBitmapFont
Global star:TImage
Global mass:TImage
Global collector:TImage
Global point:TImage
Global particle:Timage
Global pointer:TImage
+
+ Global play_button:TImage
+ Global edit_button:TImage
+ Global load_button:TImage
+ Global toy_button:TImage
+ Global quit_button:TImage
+ Global left_button:TImage
+ Global right_button:TImage
+ Global scores_button:TImage
End Type
Type TMass
@@ -205,6 +214,20 @@ Type TParticle
Return o
End Function
+ Function FromCoord:TParticle(x:Int, y:Int)
+ Local o:TParticle=New TParticle
+ o.x=x
+ o.y=y
+ o.dx=Rnd(-2,2)
+ o.dy=Rnd(-2,2)
+ o.r=Rand(128,255)
+ o.g=Rand(128,255)
+ o.b=Rand(128,255)
+ o.a=1
+ o.ai=-0.01
+ Return o
+ End Function
+
Method Update()
x:+dx
y:+dy
@@ -242,6 +265,12 @@ Type TParticleMachine
Next
End Function
+ Function AddFirework(x:Int, y:Int)
+ For Local f:Int=0 To 20
+ list.AddLast(TParticle.FromCoord(x,y))
+ Next
+ End Function
+
Function Process()
Local l:TLink=list.FirstLink()
Local t:TLink