summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Default.ppinchbin419 -> 579 bytes
-rw-r--r--designer.bmx105
-rw-r--r--game.bmx15
3 files changed, 108 insertions, 12 deletions
diff --git a/Default.ppinch b/Default.ppinch
index 8ecbc3b..bd36d76 100644
--- a/Default.ppinch
+++ b/Default.ppinch
Binary files differ
diff --git a/designer.bmx b/designer.bmx
index 9f7af86..0b349a5 100644
--- a/designer.bmx
+++ b/designer.bmx
@@ -32,6 +32,8 @@ Type TDesObj Abstract
Method Drag(x:Int, y:Int) Abstract
Method Edit() Abstract
Method Save(lev:TLevel) Abstract
+ Method SetInfo(w:TLabel) Abstract
+ Method Snap() Abstract
Method DrawSelBox(x:Int, y:Int)
Local x1:Int=x-SELSIZE
@@ -58,6 +60,34 @@ Type TDesObj Abstract
Method DrawCoord(x:Int, y:Int)
GameGFX.guifont.Draw(x+","+y,0,0)
End Method
+
+ Method FloatString:String(v:Double)
+ Local s:String=v
+
+ If s.Find(".")<>-1
+ While s.length>1 And s[s.length-1]=Asc("0")
+ s=s[..s.length-1]
+ Wend
+
+ While s.length>1 And s[s.length-1]=Asc(".")
+ s=s[..s.length-1]
+ Wend
+ EndIf
+
+ Return s
+ End Method
+
+ Method BoolString:String(b:Int)
+ If b
+ Return "Yes"
+ Else
+ Return "No "
+ EndIf
+ End Method
+
+ Method CalcSnap:Int(p:Int)
+ Return (p+Designer.GRID/2-1)/Designer.GRID*Designer.GRID-1
+ End Method
End Type
Type TDesGrav Extends TDesObj
@@ -116,7 +146,7 @@ Type TDesGrav Extends TDesObj
Method Edit()
Designer.md_friendly.checked = g.friendly
Designer.md_invert.checked = g.repel
- Designer.md_mass.text = g.mass
+ Designer.md_mass.SetFloat(g.mass)
If GUIDialog(Designer.mdialog,Designer.md_ok,Designer.md_cancel,GameGFX.pointer)
g.friendly = Designer.md_friendly.checked
@@ -129,6 +159,15 @@ Type TDesGrav Extends TDesObj
lev.grav.AddLast(g)
End Method
+ Method SetInfo(w:TLabel)
+ w.text="Friendly:" + BoolString(g.friendly) + " Inverse gravity:" + BoolString(g.repel) + " Mass: " + FloatString(g.mass)
+ End Method
+
+ Method Snap()
+ g.x=CalcSnap(g.x)
+ g.y=CalcSnap(g.y)
+ End Method
+
End Type
Type TDesPoint Extends TDesObj
@@ -270,10 +309,10 @@ Type TDesPoint Extends TDesObj
Method Edit()
Designer.pd_gap.text = l.gap
- Designer.pd_vx.text = l.v.x
- Designer.pd_vy.text = l.v.y
+ Designer.pd_vx.SetFloat(l.v.x)
+ Designer.pd_vy.SetFloat(l.v.y)
Designer.pd_circle.checked = l.circle
- Designer.pd_circvel.text = l.circvel
+ Designer.pd_circvel.SetFloat(l.circvel)
If GUIDialog(Designer.pdialog,Designer.pd_ok,Designer.pd_cancel,GameGFX.pointer)
l.gap = Max(1,Designer.pd_gap.text.ToInt())
@@ -288,6 +327,35 @@ Type TDesPoint Extends TDesObj
lev.point.AddLast(l)
End Method
+ Method SetInfo(w:TLabel)
+ If l.circle
+ w.text="Gap:" + l.gap + " DX: " + FloatString(l.v.x) + " DY: " + FloatString(l.v.y) + " Angular velocity: " + FloatString(l.circvel)
+ Else
+ w.text="Gap:" + l.gap + " DX: " + FloatString(l.v.x) + " DY: " + FloatString(l.v.y)
+ EndIf
+ End Method
+
+ Method Snap()
+ If l.circle
+ If over_p1
+ l.x1=CalcSnap(l.x1)
+ l.y1=CalcSnap(l.y1)
+ Else
+ l.x2=CalcSnap(l.x2)
+ l.y1=CalcSnap(l.y1)
+ l.y2=l.y1
+ EndIf
+ Else
+ If over_p1
+ l.x1=CalcSnap(l.x1)
+ l.y1=CalcSnap(l.y1)
+ Else
+ l.x2=CalcSnap(l.x2)
+ l.y2=CalcSnap(l.y2)
+ EndIf
+ EndIf
+ End Method
+
End Type
' **** Globals
@@ -296,7 +364,8 @@ End Type
'
Type Designer
Const TEXTX:Int=100
-
+ Const GRID:Int=20
+
Global init:Int=False
Global obj:TList
@@ -321,7 +390,10 @@ Type Designer
Global levdel_but:TButton
Global levnum:TNumberInt
+ Global info:TLabel
+
Global hide_check:TCheckbox
+ Global grid_check:TCheckbox
Global validbut:TButton
Global helpbut:TButton
@@ -390,7 +462,11 @@ Type Designer
levnum.minval = 0
levnum.maxval = 0
+ info = TLabel.Create(gui,0,50,"")
+
hide_check = TCheckbox.Create(gui,750,0,"Hide",HideCallback)
+ grid_check = TCheckbox.Create(gui,750,15,"Grid")
+ grid_check.checked=True
validbut = TButton.Create(gui,650,570,49,29,"Check",CheckCallback)
helpbut = TButton.Create(gui,700,570,49,29,"Test",TestCallback)
@@ -474,7 +550,7 @@ Type Designer
ld_maxmass.text = level.maxmass
ld_winpercent.text = level.winpercent
ld_timer.text = level.timer
- ld_placemass.text = level.placemass
+ ld_placemass.SetFloat(level.placemass)
If GUIDialog(ldialog,ld_ok,ld_cancel,GameGFX.pointer)
level.invmass = ld_invert.checked
@@ -500,7 +576,17 @@ Function DoDesigner()
While Not Designer.done
Cls
-
+
+ If Designer.grid_check.checked
+ SetColor(50,50,128)
+ For Local x:Int=-400 To 400 Step 20
+ DrawLine(399+x,0,399+x,599)
+ Next
+ For Local y:Int=-300 To 300 Step 20
+ DrawLine(0,299+y,799,299+y)
+ Next
+ EndIf
+
If Not drag
Designer.gui.EventLoop()
EndIf
@@ -521,6 +607,7 @@ Function DoDesigner()
Next
If sel<>Null
+ sel.SetInfo(Designer.info)
sel.DrawSelect()
EndIf
@@ -530,10 +617,12 @@ Function DoDesigner()
If KeyHit(KEY_MOUSERIGHT)
If sel<>Null
- Select GUIMenu("Object Menu",["Edit","Delete"],x,y,GameGFX.pointer)
+ Select GUIMenu("Object Menu",["Edit","Snap to grid","Delete"],x,y,GameGFX.pointer)
Case 0
sel.Edit()
Case 1
+ sel.Snap()
+ Case 2
Designer.obj.Remove(sel)
End Select
Else
diff --git a/game.bmx b/game.bmx
index 8c66ef8..c11fbc3 100644
--- a/game.bmx
+++ b/game.bmx
@@ -142,7 +142,13 @@ Type TGame
EndIf
EndIf
- Local percent:Int=Int(Float(captured)/Float(num)*100.0)
+ Local percent:Int
+
+ If done<>LEVEL_NOTOVER
+ percent=final_percent
+ Else
+ percent:Int=Int(Float(captured)/Float(num)*100.0)
+ EndIf
If (timer=0 Or num=captured+lost) And done=LEVEL_NOTOVER
final_percent=percent
@@ -157,10 +163,11 @@ Type TGame
GameGFX.font.DrawColoured(num-captured-lost,txtoff[0]+10,0,255,255,0)
GameGFX.font.Draw("CAPTURED",200,0)
- If done=LEVEL_NOTOVER
- GameGFX.font.DrawColoured(percent+"%",txtoff[1]+210,0,255,0,255)
+
+ If percent<level.winpercent
+ GameGFX.font.DrawColoured(percent+"%",txtoff[1]+210,0,255,50,50)
Else
- GameGFX.font.DrawColoured(final_percent+"%",txtoff[1]+210,0,255,0,255)
+ GameGFX.font.DrawColoured(percent+"%",txtoff[1]+210,0,50,255,50)
EndIf
GameGFX.font.Draw("TIMER",600,0)