From f52fff7f3f56fbf79fd05017c0ae0f0836d3d6e2 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 25 Sep 2005 01:47:37 +0000 Subject: Updates for designer --- Default.ppinch | Bin 60 -> 60 bytes designer.bmx | 361 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- level.bmx | 11 +- 3 files changed, 337 insertions(+), 35 deletions(-) diff --git a/Default.ppinch b/Default.ppinch index 260e8b7..529588e 100644 Binary files a/Default.ppinch and b/Default.ppinch differ diff --git a/designer.bmx b/designer.bmx index b6f12de..a29a19e 100644 --- a/designer.bmx +++ b/designer.bmx @@ -8,6 +8,7 @@ Strict Import noddybox.vector Import noddybox.bitmapfont Import noddybox.simplegui +Import noddybox.algorithm Import "types.bmx" Import "level.bmx" Import "game.bmx" @@ -18,13 +19,235 @@ End Function Private +' **** Types +' +Type TDesObj Abstract + Const SELSIZE:Int=3 + + Function Create:TDesObj(x:Int, y:Int) Abstract + Function CreateFromLevel:TDesObj(o:Object) Abstract + Method Draw() Abstract + Method DrawSelect() Abstract + Method MouseOver:Int(x:Int, y:Int) Abstract + Method Drag(x:Int, y:Int) Abstract + Method Edit() Abstract + Method Save(l:TLevel) Abstract + + Method DrawSelBox(x:Int, y:Int) + Local x1:Int=x-SELSIZE + Local y1:Int=y-SELSIZE + Local x2:Int=x+SELSIZE + Local y2:Int=y+SELSIZE + + SetColor(255,255,255) + DrawLine(x1,y1,x2,y1) + DrawLine(x2,y1,x2,y2) + DrawLine(x2,y2,x1,y2) + DrawLine(x1,y2,x1,y1) + End Method + + Method InSelBox(px:Int, py:Int, x:Int, y:Int) + Local x1:Int=x-SELSIZE + Local y1:Int=y-SELSIZE + Local x2:Int=x+SELSIZE + Local y2:Int=y+SELSIZE + + Return px>=x1 And px<=x2 And py>=y1 And py<=y2 + End Method +End Type + +Type TDesGrav Extends TDesObj + Field g:TGravPoint + + Function Create:TDesObj(x:Int, y:Int) + Local o:TDesGrav=New TDesGrav + + o.g=New TGravPoint + o.g.x=x + o.g.y=y + o.g.friendly=False + o.g.mass=25 + o.g.repel=False + + Return o + End Function + + Function CreateFromLevel:TDesObj(o:Object) + Local lp:TGravPoint=TGravPoint(o) + Local no:TDesGrav=New TDesGrav + + no.g=New TGravPoint + no.g.x=lp.x + no.g.y=lp.y + no.g.friendly=lp.friendly + no.g.mass=lp.mass + no.g.repel=lp.repel + + Return no + End Function + + Method Draw() + If g.friendly + SetColor(0,255,0) + Else + SetColor(255,0,0) + EndIf + + DrawOval(g.x-MASSRAD,g.y-MASSRAD,MASSSIZE,MASSSIZE) + End Method + + Method DrawSelect() + DrawSelBox(g.x,g.y) + End Method + + Method MouseOver:Int(x:Int, y:Int) + Return InSelBox(x,y,g.x,g.y) + End Method + + Method Drag(x:Int, y:Int) + g.x=x + g.y=y + End Method + + Method Edit() + Designer.md_friendly.checked = g.friendly + Designer.md_invert.checked = g.repel + Designer.md_mass.text = g.mass + + If GUIDialog(Designer.mdialog,Designer.md_ok,Designer.md_cancel,GameGFX.pointer) + g.friendly = Designer.md_friendly.checked + g.repel = Designer.md_invert.checked + g.mass = Designer.md_mass.text.ToFloat() + EndIf + End Method + + Method Save(l:TLevel) + l.grav.AddLast(g) + End Method + +End Type + +Type TDesPoint Extends TDesObj + Field l:TPointLine + Field over_p1:Int + + Function Create:TDesObj(x:Int, y:Int) + Local o:TDesPoint=New TDesPoint + + o.over_p1=False + + o.l=New TPointLine + o.l.x1=x + o.l.y1=y + o.l.y2=y + + If xNull + sel.DrawSelect() + EndIf + + If drag + sel.Drag(x,y) + EndIf + + If KeyHit(KEY_MOUSERIGHT) + If sel<>Null + Select GUIMenu("Object Menu",["Edit","Delete"],x,y,GameGFX.pointer) + Case 0 + sel.Edit() + Case 1 + Designer.obj.Remove(sel) + End Select + Else + Select GUIMenu("Create Menu",["Create Gravity Point","Create Particle Line"],x,y,GameGFX.pointer) + Case 0 + Designer.obj.AddLast(TDesGrav.Create(x,y)) + Case 1 + Designer.obj.AddLast(TDesPoint.Create(x,y)) + End Select + EndIf + sel=Null + EndIf + + If Not drag + If KeyDown(KEY_MOUSELEFT) And sel<>Null + drag=True + EndIf + Else + If Not KeyDown(KEY_MOUSELEFT) + drag=False + EndIf + EndIf + SetColor(255,255,255) DrawImage(GameGFX.pointer,MouseX(),MouseY()) + Flip FlushMem Wend diff --git a/level.bmx b/level.bmx index ba0ea40..95aba16 100644 --- a/level.bmx +++ b/level.bmx @@ -15,9 +15,6 @@ Const MAGIC:String="PPINCH0.0" Const MAX_GRAV:Int=10 Const MAX_POINT:Int=1000 -Const GRAV_ATTRACT:Int=0 -Const GRAV_REPEL:Int=0 - Type TLevelException Field message:String @@ -29,7 +26,7 @@ Type TLevelException End Type Type TGravPoint - Field mode:Int + Field repel:Int Field friendly:Int Field x:Float Field y:Float @@ -49,12 +46,12 @@ Type TGravPoint m.x=x m.y=y - m.inverse=(mode=GRAV_REPEL) + m.inverse=repel End Method Function FromStream:TGravPoint(s:TStream) Local o:TGravPoint=New TGravPoint - o.mode=s.ReadInt() + o.repel=s.ReadInt() o.friendly=s.ReadInt() o.x=s.ReadFloat() o.y=s.ReadFloat() @@ -63,7 +60,7 @@ Type TGravPoint End Function Method ToStream(s:TStream) - s.WriteInt(mode) + s.WriteInt(repel) s.WriteInt(friendly) s.WriteFloat(x) s.WriteFloat(y) -- cgit v1.2.3