summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GFX/COLLECTOR.pngbin0 -> 195 bytes
-rw-r--r--GFX/POINTER.pngbin225 -> 230 bytes
-rw-r--r--GFX/STAR.pngbin195 -> 198 bytes
-rw-r--r--GFX/gui.bmfbin0 -> 19840 bytes
-rw-r--r--GFX/sprites.bmsbin2692 -> 3237 bytes
-rw-r--r--designer.bmx129
-rw-r--r--game.bmx171
-rw-r--r--level.bmx242
-rw-r--r--main.bmx175
-rw-r--r--types.bmx27
10 files changed, 596 insertions, 148 deletions
diff --git a/GFX/COLLECTOR.png b/GFX/COLLECTOR.png
new file mode 100644
index 0000000..6fef517
--- /dev/null
+++ b/GFX/COLLECTOR.png
Binary files differ
diff --git a/GFX/POINTER.png b/GFX/POINTER.png
index c520048..4066a1f 100644
--- a/GFX/POINTER.png
+++ b/GFX/POINTER.png
Binary files differ
diff --git a/GFX/STAR.png b/GFX/STAR.png
index 6fef517..4b612b9 100644
--- a/GFX/STAR.png
+++ b/GFX/STAR.png
Binary files differ
diff --git a/GFX/gui.bmf b/GFX/gui.bmf
new file mode 100644
index 0000000..8ef2706
--- /dev/null
+++ b/GFX/gui.bmf
Binary files differ
diff --git a/GFX/sprites.bms b/GFX/sprites.bms
index 59a5d29..dc8052a 100644
--- a/GFX/sprites.bms
+++ b/GFX/sprites.bms
Binary files differ
diff --git a/designer.bmx b/designer.bmx
new file mode 100644
index 0000000..7546823
--- /dev/null
+++ b/designer.bmx
@@ -0,0 +1,129 @@
+' Particle Pinch
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import noddybox.vector
+Import noddybox.bitmapfont
+Import noddybox.simplegui
+Import "types.bmx"
+Import "level.bmx"
+Import "game.bmx"
+
+Function LevelDesigner()
+ DoDesigner()
+End Function
+
+Private
+
+' **** Globals
+'
+Type Designer
+ Const TEXTX:Int=100
+
+ Global init:Int=False
+
+ Global levelset:TLevelSet
+ Global level:TLevel
+ Global levelsetfname:String
+ Global done:Int
+ Global levelindex:Int
+
+ Global gui:TGUIHandler
+
+ Global fname_lab:TLabel
+ Global fname_txt:TText
+
+ Global setname_lab:TLabel
+ Global setname_txt:TText
+
+ Global levname_lab:TLabel
+ Global levname_txt:TText
+
+ Global hide_check:TCheckbox
+
+ Global validbut:TButton
+ Global helpbut:TButton
+ Global quitbut:TButton
+
+ Function Initialise()
+ If Not init
+ TGUIFont.font = GameGFX.guifont
+
+ levelset = New TLevelSet
+ level = New TLevel
+ levelsetfname = "Default.ppinch"
+ done = False
+ levelindex = 0
+
+ gui = TGUIHandler.Create()
+
+ fname_lab = TLabel.Create(gui,0,0,"File")
+ fname_txt = TText.Create(gui,TEXTX,0,"",32)
+
+ setname_lab = TLabel.Create(gui,0,10,"Levelset name")
+ setname_txt = TText.Create(gui,TEXTX,10,"",32)
+
+ levname_lab = TLabel.Create(gui,0,20,"Level name")
+ levname_txt = TText.Create(gui,TEXTX,20,"",32)
+
+ hide_check = TCheckbox.Create(gui,700,0,"Hide GUI",HideCallback)
+
+ validbut = TButton.Create(gui,650,570,49,29,"Check",CheckCallback)
+ helpbut = TButton.Create(gui,700,570,49,29,"Test",TestCallback)
+ quitbut = TButton.Create(gui,750,570,49,29,"Quit",QuitCallback)
+ levelset.level.AddLast(level)
+ init=True
+ EndIf
+
+ fname_txt.text = levelsetfname
+ setname_txt.text = levelset.name
+ levname_txt.text = level.name
+ End Function
+End Type
+
+
+' **** Main Loop
+'
+Function DoDesigner()
+ Designer.Initialise()
+
+ Designer.done=False
+
+ While Not Designer.done
+ Cls
+ Designer.gui.EventLoop()
+ DrawImage(GameGFX.pointer,MouseX(),MouseY())
+ Flip
+ FlushMem
+ Wend
+End Function
+
+
+' **** Utils
+'
+Function LoadLevel()
+End Function
+
+Function SaveLevel()
+End Function
+
+' **** Callbacks
+'
+Function HideCallback(w:TWidget)
+ Local c:TCheckbox=TCheckbox(w)
+ Designer.gui.SetEnable(Not c.checked)
+ c.enabled=True
+End Function
+
+Function QuitCallback(w:TWidget)
+ Designer.done=GUIYesNo("Quit back to the|main menu of Particle Pinch?",GameGFX.pointer)
+End Function
+
+Function TestCallback(w:TWidget)
+End Function
+
+Function CheckCallback(w:TWidget)
+End Function
diff --git a/game.bmx b/game.bmx
new file mode 100644
index 0000000..cc5a8b9
--- /dev/null
+++ b/game.bmx
@@ -0,0 +1,171 @@
+' Particle Pinch
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import noddybox.vector
+Import noddybox.bitmapfont
+Import "types.bmx"
+Import "level.bmx"
+
+Const LEVEL_NOTOVER:Int= 0
+Const LEVEL_WON:Int= 1
+Const LEVEL_LOST:Int= 2
+
+Type TGame
+
+ Field level:TLevel
+ Field mass:TList
+ Field point:TList
+ Field timer:Int
+ Field num:Int
+ Field lost:Int
+ Field captured:Int
+ Field done:Int
+ Field frame:Int
+ Field placed:Int
+ Field txtoff:Int[]
+ Field playing:Int
+ Field col:Int
+ Field coli:Int
+
+ Function Create:TGame(level:TLevel)
+ Local o:TGame=New TGame
+
+ o.level=level
+ o.mass=CreateList()
+ o.point=CreateList()
+ o.level.CreatePlayfield(o.mass,o.point)
+ o.timer=o.level.timer
+ o.num=o.point.Count()
+ o.done=LEVEL_NOTOVER
+ o.frame=0
+ o.placed=0
+ o.txtoff=[GameGFX.font.TextWidth("PARTICLES"),GameGFX.font.TextWidth("CAPTURED"),GameGFX.font.TextWidth("LOST"),GameGFX.font.TextWidth("TIMER")]
+ o.playing=False
+ o.col=0
+ o.coli=1
+ Return o
+ End Function
+
+ Method Intro()
+ Local y:Int=GraphicsHeight()/4
+ Local yi:Int=25
+ col:+coli
+
+ If col=255 Or col=128
+ coli=-coli
+ EndIf
+
+ SetScale(2,2)
+
+ GameGFX.font.CentreColoured(level.name,y,col,col,255-col)
+ y:+yi
+
+ GameGFX.font.CentreColoured("Need "+level.winpercent+"% to clear",GraphicsHeight()/2,col/2,col,col)
+ y:+yi
+
+ GameGFX.font.CentreColoured("You can place "+level.maxmass+" masses",GraphicsHeight()/2,col/2,col,col)
+ y:+yi
+
+ If level.invmass
+ GameGFX.font.CentreColoured("PLACED MASSES ARE INVERTED!",y,col,col/2,col/2)
+ y:+yi
+ EndIf
+
+ SetScale(1,1)
+ End Method
+
+ Method Play:Int()
+ captured=0
+ lost=0
+
+ For Local m:TMass=EachIn mass
+ For Local s:TPoint=EachIn point
+ s.Attract(m)
+ Next
+ Next
+
+ TParticleMachine.Process()
+
+ For Local m:TMass=EachIn mass
+ m.MoveAndDraw()
+ Next
+
+ For Local s:TPoint=EachIn point
+ s.MoveAndDraw()
+
+ If s.dead
+ captured:+1
+ ElseIf s.lost
+ lost:+1
+ EndIf
+ Next
+
+ frame:+1
+
+ If frame=60 And timer>0
+ timer:-1
+ EndIf
+
+ Local percent:Int=Int(Float(captured)/Float(num)*100.0)
+
+ If (timer=0 Or num=0) And done=LEVEL_NOTOVER
+ If percent>=level.winpercent
+ done=LEVEL_WON
+ Else
+ done=LEVEL_LOST
+ EndIf
+ EndIf
+
+ GameGFX.font.Draw("PARTICLES",0,0)
+ GameGFX.font.DrawColoured(num-captured-lost,txtoff[0]+10,0,255,255,0)
+ GameGFX.font.Draw("CAPTURED",200,0)
+ GameGFX.font.DrawColoured(percent+"%",txtoff[1]+210,0,255,0,255)
+ GameGFX.font.Draw("LOST",400,0)
+ GameGFX.font.DrawColoured((100-percent)+"%",txtoff[2]+410,0,255,0,0)
+
+ GameGFX.font.Draw("TIMER",600,0)
+
+ If timer>10
+ GameGFX.font.Draw(timer,txtoff[3]+610,0)
+ Else
+ GameGFX.font.DrawColoured(timer,txtoff[3]+610,0,255,0,0)
+ EndIf
+
+ Select done
+ Case LEVEL_NOTOVER
+ If playing
+ If placed<level.maxmass And mass.Count()<MAX_GRAV
+ If MouseHit(1)
+ Local m:TMass=New TMass
+ m.friend=False
+ m.inverse=level.invmass
+ m.x=MouseX()
+ m.y=MouseY()
+ m.img=GameGFX.mass
+ mass.AddLast(m)
+ EndIf
+ EndIf
+ Else
+ Intro()
+ If MouseHit(1)
+ playing=True
+ EndIf
+ EndIf
+ Case LEVEL_WON
+ SetScale(2,2)
+ GameGFX.font.CentreColoured("LEVEL COMPLETED!",GraphicsHeight()/2,255,255,0)
+ SetScale(1,1)
+ Case LEVEL_LOST
+ SetScale(2,2)
+ GameGFX.font.CentreColoured("LEVEL FAILED!",GraphicsHeight()/2,255,64,64)
+ SetScale(1,1)
+ EndSelect
+
+ Return done
+ End Method
+
+End Type \ No newline at end of file
diff --git a/level.bmx b/level.bmx
new file mode 100644
index 0000000..50411a1
--- /dev/null
+++ b/level.bmx
@@ -0,0 +1,242 @@
+' Particle Pinch
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import noddybox.vector
+Import noddybox.bitmapfont
+Import "types.bmx"
+
+Const MAGIC:String="$Version$"
+
+Const MAX_GRAV:Int=10
+Const MAX_POINT:Int=1000
+
+Const GRAV_ATTRACT:Int=0
+Const GRAV_REPEL:Int=0
+
+Const LINE_EVEN:Int=0
+Const LINE_RAND:Int=1
+
+Type TLevelException
+ Field message:String
+
+ Function Error(msg:String)
+ Local o:TLevelException=New TLevelException
+ o.message=msg
+ Throw o
+ End Function
+End Type
+
+Type TGravPoint
+ Field mode:Int
+ Field friendly:Int
+ Field x:Float
+ Field y:Float
+ Field mass:Float
+
+ Method CreateMass:TMass()
+ Local m:TMass=New TMass
+ m.mass=mass
+
+ If friendly
+ m.img=GameGFX.collector
+ m.friend=True
+ Else
+ m.img=GameGFX.star
+ m.friend=False
+ EndIf
+
+ m.x=x
+ m.y=y
+ m.inverse=(mode=GRAV_REPEL)
+ End Method
+
+ Function FromStream:TGravPoint(s:TStream)
+ Local o:TGravPoint=New TGravPoint
+ o.mode=s.ReadInt()
+ o.friendly=s.ReadInt()
+ o.x=s.ReadFloat()
+ o.y=s.ReadFloat()
+ o.mass=s.ReadFloat()
+ Return o
+ End Function
+
+ Method ToStream(s:TStream)
+ s.WriteInt(mode)
+ s.WriteInt(friendly)
+ s.WriteFloat(x)
+ s.WriteFloat(y)
+ s.WriteFloat(mass)
+ End Method
+End Type
+
+Type TPointLine
+ Field mode:Int
+ Field x1:Float
+ Field y1:Float
+ Field x2:Float
+ Field y2:Float
+ Field num:Int
+ Field v:TVector
+
+ Method New()
+ v=TVector.Create()
+ End Method
+
+ Method CreatePoints(l:TList)
+ End Method
+
+ Function FromStream:TPointLine(s:TStream)
+ Local o:TPointLine=New TPointLine
+ o.mode=s.ReadInt()
+ o.x1=s.ReadFloat()
+ o.y1=s.ReadFloat()
+ o.x2=s.ReadFloat()
+ o.y2=s.ReadFloat()
+ o.num=s.ReadInt()
+ o.v.x=s.ReadInt()
+ o.v.y=s.ReadInt()
+ Return o
+ End Function
+
+ Method ToStream(s:TStream)
+ s.WriteInt(mode)
+ s.WriteFloat(x1)
+ s.WriteFloat(y1)
+ s.WriteFloat(x2)
+ s.WriteFloat(y2)
+ s.WriteInt(num)
+ s.WriteInt(v.x)
+ s.WriteInt(v.y)
+ End Method
+End Type
+
+Type TLevel
+ Field name:String
+ Field maxmass:Int
+ Field grav:TList
+ Field point:TList
+ Field winpercent:Int
+ Field timer:Int
+ Field invmass:Int
+
+ Method New()
+ grav=CreateList()
+ point=CreateList()
+ name="Unititled"
+ maxmass=5
+ winpercent=50
+ timer=60
+ invmass=False
+ End Method
+
+ Method CreatePlayfield(masslist:TList, pointlist:TList)
+ For Local gp:TGravPoint=EachIn grav
+ masslist.AddLast(gp.CreateMass())
+ Next
+ For Local lp:TPointLine=EachIn point
+ lp.CreatePoints(pointlist)
+ Next
+ End Method
+
+ Function FromStream:TLevel(s:TStream)
+ Local o:TLevel=New TLevel
+ Local c:Int
+
+ o.name=s.ReadLine()
+ o.maxmass=s.ReadInt()
+ o.winpercent=s.ReadInt()
+ o.timer=s.ReadInt()
+ o.invmass=s.ReadInt()
+
+ c=s.ReadInt()
+ For Local f:Int=1 To c
+ o.grav.AddLast(TGravPoint.FromStream(s))
+ Next
+
+ c=s.ReadInt()
+ For Local f:Int=1 To c
+ o.point.AddLast(TPointLine.FromStream(s))
+ Next
+
+ Return o
+ End Function
+
+ Method ToStream(s:TStream)
+ s.WriteLine(name)
+ s.WriteInt(maxmass)
+ s.WriteInt(winpercent)
+ s.WriteInt(timer)
+ s.WriteInt(invmass)
+ s.WriteInt(grav.Count())
+ For Local o:TGravPoint=EachIn grav
+ o.ToStream(s)
+ Next
+ s.WriteInt(point.Count())
+ For Local o:TPointLine=EachIn point
+ o.ToStream(s)
+ Next
+ End Method
+End Type
+
+
+Type TLevelSet
+ Field name:String
+ Field level:TList
+
+ Method New()
+ level=CreateList()
+ name="Untitled"
+ End Method
+
+ Function FromStream:TLevelSet(file:String)
+ Local s:TStream=ReadStream(file)
+
+ If s=Null
+ TLevelException.Error(file + " couldn't be opened")
+ EndIf
+
+ Local o:TLevelSet=New TLevelSet
+ Local c:Int
+
+ Local m:String=s.ReadLine()
+
+ If m<>MAGIC
+ s.Close()
+ TLevelException.Error(file + " doesn't appear to be a valid file for this version")
+ EndIf
+
+ o.name=s.ReadLine()
+
+ c=s.ReadInt()
+ For Local f:Int=1 To c
+ o.level.AddLast(TLevel.FromStream(s))
+ Next
+
+ s.Close()
+
+ Return o
+ End Function
+
+ Method ToStream:Int(file:String)
+ Local s:TStream=WriteStream(file)
+
+ If s=Null
+ Return False
+ EndIf
+
+ s.WriteLine(MAGIC)
+ s.WriteLine(name)
+ s.WriteInt(level.Count())
+ For Local o:TLevel=EachIn level
+ o.ToStream(s)
+ Next
+
+ s.Close()
+
+ Return True
+ End Method
+End Type
diff --git a/main.bmx b/main.bmx
index f6ca18d..2d0e539 100644
--- a/main.bmx
+++ b/main.bmx
@@ -1,23 +1,30 @@
-' It's all a bit rolly
+' Particle Pinch
+'
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
'
Strict
Import noddybox.vector
Import noddybox.bitmapfont
+Import noddybox.simplegui
-' Includes
-'
-Include "types.bmx"
-
+Import "types.bmx"
+Import "level.bmx"
+Import "game.bmx"
+Import "designer.bmx"
' Included binaries
'
Incbin "GFX/font.bmf"
+Incbin "GFX/gui.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"
' Initialise graphics
@@ -30,21 +37,24 @@ SetBlend(ALPHABLEND)
' Globals
'
-Global font:TBitmapFont=TBitmapFont.Load("incbin::GFX/font.bmf",0)
-Global star_img:TImage=LoadAnimImage("incbin::GFX/STAR.png",8,8,0,2)
-Global mass_img:TImage=LoadAnimImage("incbin::GFX/MASS.png",8,8,0,2)
-Global point_img:TImage=LoadImage("incbin::GFX/POINT.png",0)
-Global particle_img:TImage=LoadImage("incbin::GFX/PARTICLE.png",0)
-Global pointer_img:TImage=LoadImage("incbin::GFX/POINTER.png",0)
-
-SetImageHandle(star_img,3,3)
-SetImageHandle(mass_img,3,3)
-SetImageHandle(point_img,3,3)
-SetImageHandle(particle_img,3,3)
-SetImageHandle(pointer_img,0,0)
-
-TPoint.img=point_img
-TParticle.img=particle_img
+GameGFX.font=TBitmapFont.Load("incbin::GFX/font.bmf",0)
+GameGFX.guifont=TBitmapFont.Load("incbin::GFX/gui.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.particle=LoadImage("incbin::GFX/PARTICLE.png",0)
+GameGFX.pointer=LoadImage("incbin::GFX/POINTER.png",0)
+
+SetImageHandle(GameGFX.star,3,3)
+SetImageHandle(GameGFX.mass,3,3)
+SetImageHandle(GameGFX.collector,3,3)
+SetImageHandle(GameGFX.point,3,3)
+SetImageHandle(GameGFX.particle,3,3)
+SetImageHandle(GameGFX.pointer,0,0)
+
+TPoint.img=GameGFX.point
+TParticle.img=GameGFX.particle
TParticleMachine.Init()
@@ -53,130 +63,7 @@ TParticleMachine.Init()
' Test code
'
-Global main_mass:TMass=New TMass
-Global mass:TList=CreateList()
-Global star:TList=CreateList()
-Global cx:Int=GraphicsWidth()/2
-Global cy:Int=GraphicsHeight()/2
-
-main_mass.x=cx'/2
-main_mass.y=cy
-main_mass.friend=False
-'main_mass.inverse=True
-main_mass.img=star_img
-
-For Local r:Int=0 Until 1000
- Local s:TPoint=New TPoint
- Local d:Float
- Local a:Float
- s=New TPoint
- d=Rnd(50,100)
- 'a=Rnd(0,360)
- a=Rand(0,3)*90
- s.x=main_mass.x+d*Sin(a)
- s.y=main_mass.y+d*Cos(a)
- s.v.x=Sin(a+90)/(d/30)
- s.v.y=Cos(a+90)/(d/30)
- star.AddLast(s)
-Next
-
-mass.AddLast(main_mass)
-
-TParticleMachine.Clear()
-
-While Not KeyHit(KEY_ESCAPE)
- Cls
-
- Local dead:Int=0
- Local lost:Int=0
-
- For Local m:TMass=EachIn mass
- For Local s:TPoint=EachIn star
- s.Attract(m)
- Next
- Next
-
- TParticleMachine.Process()
-
- For Local m:TMass=EachIn mass
- m.MoveAndDraw()
- Next
-
- For Local s:TPoint=EachIn star
- s.MoveAndDraw()
-
- If s.dead
- dead:+1
- ElseIf s.lost
- lost:+1
- EndIf
- Next
-
- font.Draw("PARTICLES",0,0)
- font.DrawColoured(star.Count()-dead-lost,font.TextWidth("PARTICLES")+10,0,255,255,0)
- font.Draw("CAPTURED",200,0)
- font.DrawColoured(dead,font.TextWidth("CAPTURED")+210,0,255,0,255)
- font.Draw("LOST",400,0)
- font.DrawColoured(lost,font.TextWidth("LOST")+410,0,255,0,0)
-
- If MouseHit(1)
- Local m:TMass=New TMass
- m.x=MouseX()
- m.y=MouseY()
- m.img=mass_img
- mass.AddLast(m)
- EndIf
-
- SetColor(255,255,255)
- DrawImage(pointer_img,MouseX(),MouseY())
- FlushMem
- Flip
-Wend
-
-
-
-' Globals
-'
-Rem
-Global player:TBall=New TBall
-player.r=255
-player.g=255
-player.b=255
-
-Global balls:TList=CreateList()
-
-balls.AddLast(player)
-
-For Local f:Int=0 To 10
- balls.AddLast(New TBall)
-Next
-
-While Not KeyHit(KEY_ESCAPE)
- Cls
-
- If KeyHit(KEY_MOUSELEFT)
- player.v.x=MouseX()-player.x
- player.v.y=MouseY()-player.y
- player.v.Normalise()
- player.v.Scale(2)
- EndIf
-
- For Local b1:TBall=EachIn balls
- For Local b2:TBall=EachIn balls
- If b1<>b2
- b1.Collide(b2)
- EndIf
- Next
- Next
-
- For Local b1:TBall=EachIn balls
- b1.MoveAndDraw()
- Next
-
- FlushMem
- Flip
-Wend
-EndRem
+LevelDesigner()
EndGraphics
End \ No newline at end of file
diff --git a/types.bmx b/types.bmx
index 6622ce4..2f83707 100644
--- a/types.bmx
+++ b/types.bmx
@@ -1,7 +1,26 @@
-' It's all a bit rolly
+' Particle Pinch
'
-Global MASSSIZE:Int=6
-Global MASSRAD:Int=3
+' Copyright 2005 Ian Cowburn
+'
+' $Id$
+'
+Strict
+Import noddybox.vector
+Import noddybox.bitmapfont
+
+Const MASSSIZE:Int=6
+Const MASSRAD:Int=3
+
+Type GameGFX
+ Global font:TBitmapFont
+ Global guifont:TBitmapFont
+ Global star:TImage
+ Global mass:TImage
+ Global collector:TImage
+ Global point:TImage
+ Global particle:Timage
+ Global pointer:TImage
+End Type
Type TMass
Field x:Float
@@ -20,7 +39,7 @@ Type TMass
mass=25
friend=True
inverse=False
- swallow=False
+ swallow=0
End Method
Method Attract(o:TMass)