summaryrefslogtreecommitdiff
path: root/designer.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'designer.bmx')
-rw-r--r--designer.bmx204
1 files changed, 157 insertions, 47 deletions
diff --git a/designer.bmx b/designer.bmx
index a45034d..ff7db2f 100644
--- a/designer.bmx
+++ b/designer.bmx
@@ -22,7 +22,8 @@ Private
' **** Types
'
Type TDesObj Abstract
- Const SELSIZE:Int=3
+ Field selsize:Int
+ Field removable:Int
Function Create:TDesObj(x:Int, y:Int) Abstract
Function CreateFromLevel:TDesObj(o:Object) Abstract
@@ -36,10 +37,10 @@ Type TDesObj Abstract
Method Snap() 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
+ 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)
@@ -49,10 +50,10 @@ Type TDesObj Abstract
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
+ 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
@@ -102,6 +103,8 @@ Type TDesGrav Extends TDesObj
o.g.friendly=False
o.g.mass=25
o.g.repel=False
+ o.selsize=3
+ o.removable=True
Return o
End Function
@@ -116,6 +119,8 @@ Type TDesGrav Extends TDesObj
no.g.friendly=lp.friendly
no.g.mass=lp.mass
no.g.repel=lp.repel
+ no.selsize=3
+ no.removable=True
Return no
End Function
@@ -170,6 +175,82 @@ Type TDesGrav Extends TDesObj
End Type
+Type TDesShip Extends TDesObj
+ Field x:Int
+ Field y:Int
+ Field a:Int
+
+ Function Create:TDesShip(x:Int, y:Int)
+ Local o:TDesShip=New TDesShip
+
+ o.x=x
+ o.y=y
+ o.a=0
+ o.selsize=8
+ o.removable=False
+
+ Return o
+ End Function
+
+ Function CreateFromLevel:TDesObj(o:Object)
+ Local lp:TLevel=TLevel(o)
+ Local no:TDesShip=New TDesShip
+
+ no.x=lp.startx
+ no.y=lp.starty
+ no.a=lp.startang
+ no.selsize=8
+ no.removable=False
+
+ Return no
+ End Function
+
+ Method Draw()
+ SetColor(255,255,255)
+ SetRotation(a)
+ DrawImage(GameGFX.ship,x,y)
+ SetRotation(0)
+ End Method
+
+ Method DrawSelect()
+ DrawSelBox(x,y)
+ End Method
+
+ Method MouseOver:Int(x:Int, y:Int)
+ Return InSelBox(x,y,self.x,self.y)
+ End Method
+
+ Method Drag(x:Int, y:Int)
+ DrawCoord(x,y)
+ self.x=x
+ self.y=y
+ End Method
+
+ Method Edit()
+ Designer.sd_ang.SetFloat(a)
+
+ If GUIDialog(Designer.sdialog,Designer.sd_ok,Designer.sd_cancel,GameGFX.pointer)
+ a = Designer.sd_ang.text.ToInt()
+ EndIf
+ End Method
+
+ Method Save(lev:TLevel)
+ lev.startx=x
+ lev.starty=y
+ lev.startang=a
+ End Method
+
+ Method SetInfo(w:TLabel)
+ w.text="Angle: " + a
+ End Method
+
+ Method Snap()
+ x=CalcSnap(x)
+ y=CalcSnap(y)
+ End Method
+
+End Type
+
Type TDesPoint Extends TDesObj
Field l:TPointLine
Field over_p1:Int
@@ -193,6 +274,9 @@ Type TDesPoint Extends TDesObj
o.l.gap=1
o.l.v.x=0
o.l.v.y=0
+
+ o.selsize=3
+ o.removable=True
Return o
End Function
@@ -211,6 +295,8 @@ Type TDesPoint Extends TDesObj
no.l.v.y=lp.v.y
no.l.circle=lp.circle
no.l.circvel=lp.circvel
+ no.selsize=3
+ no.removable=True
Return no
End Function
@@ -415,13 +501,19 @@ Type Designer
Global pd_ok:TButton
Global pd_cancel:TButton
+ Global sdialog:TGUIHandler
+ Global sd_ang:TText
+ Global sd_ok:TButton
+ Global sd_cancel:TButton
+
Global ldialog:TGUIHandler
Global ld_invert:TCheckbox
- Global ld_placefriend:TCheckbox
- Global ld_maxmass:TText
+ Global ld_wrap:TCheckbox
+ Global ld_maxwave:TText
Global ld_winpercent:TText
Global ld_timer:TText
- Global ld_placemass:TText
+ Global ld_shipmass:TText
+ Global ld_wavemass:TText
Global ld_ok:TButton
Global ld_cancel:TButton
@@ -479,6 +571,13 @@ Type Designer
md_ok = TButton.Create(mdialog,p.x+5,p.y+p.h-25,p.w/2-10,20,"OK",Null)
md_cancel = TButton.Create(mdialog,p.x+p.w/2+5,p.y+p.h-25,p.w/2-10,20,"Cancel",Null)
+ sdialog = TGUIHandler.Create()
+ p = TPanel.Create(sdialog,-1,-1,400,100)
+ l = TLabel.Create(sdialog,p.x+5,p.y+50,"Angle:")
+ sd_ang = TText.Create(sdialog,p.x+l.w+10,p.y+50,"",30,TText.NUMERIC|TText.POSITIVE)
+ sd_ok = TButton.Create(sdialog,p.x+5,p.y+p.h-25,p.w/2-10,20,"OK",Null)
+ sd_cancel = TButton.Create(sdialog,p.x+p.w/2+5,p.y+p.h-25,p.w/2-10,20,"Cancel",Null)
+
pdialog = TGUIHandler.Create()
p = TPanel.Create(pdialog,-1,-1,400,200)
l = TLabel.Create(pdialog,p.x+5,p.y+10,"Gap per point:")
@@ -495,16 +594,18 @@ Type Designer
ldialog = TGUIHandler.Create()
p = TPanel.Create(ldialog,-1,-1,400,200)
- ld_invert = TCheckbox.Create(ldialog,p.x+5,p.y+10,"Inverse gravity for dropped masses?")
- ld_placefriend = TCheckbox.Create(ldialog,p.x+5,p.y+30,"Dropped masses are collectors (friendly)?")
- l = TLabel.Create(ldialog,p.x+5,p.y+50,"Max Dropped Masses:")
- ld_maxmass = TText.Create(ldialog,l.x+l.w+10,l.y,"",2,TText.NUMERIC|TText.INTEGER|TText.POSITIVE)
+ ld_invert = TCheckbox.Create(ldialog,p.x+5,p.y+10,"Ship has inverse gravity?")
+ ld_wrap = TCheckbox.Create(ldialog,p.x+5,p.y+30,"Universe wraps?")
+ l = TLabel.Create(ldialog,p.x+5,p.y+50,"Gravity Waves:")
+ ld_maxwave = TText.Create(ldialog,l.x+l.w+10,l.y,"",2,TText.NUMERIC|TText.INTEGER|TText.POSITIVE)
l = TLabel.Create(ldialog,p.x+5,p.y+70,"Win percentage:")
ld_winpercent = TText.Create(ldialog,l.x+l.w+10,l.y,"",3,TText.NUMERIC|TText.INTEGER|TText.POSITIVE)
l = TLabel.Create(ldialog,p.x+5,p.y+90,"Timer (roughly seconds):")
ld_timer = TText.Create(ldialog,l.x+l.w+10,l.y,"",3,TText.NUMERIC|TText.INTEGER|TText.POSITIVE)
- l = TLabel.Create(ldialog,p.x+5,p.y+110,"Placed mass:")
- ld_placemass = TText.Create(ldialog,l.x+l.w+10,l.y,"",20,TText.NUMERIC|TText.POSITIVE)
+ l = TLabel.Create(ldialog,p.x+5,p.y+110,"Ship mass:")
+ ld_shipmass = TText.Create(ldialog,l.x+l.w+10,l.y,"",20,TText.NUMERIC|TText.POSITIVE)
+ l = TLabel.Create(ldialog,p.x+5,p.y+130,"Gravity Wave mass:")
+ ld_wavemass = TText.Create(ldialog,l.x+l.w+10,l.y,"",20,TText.NUMERIC|TText.POSITIVE)
ld_ok = TButton.Create(ldialog,p.x+5,p.y+p.h-25,p.w/2-10,20,"OK",Null)
ld_cancel = TButton.Create(ldialog,p.x+p.w/2+5,p.y+p.h-25,p.w/2-10,20,"Cancel",Null)
@@ -523,6 +624,8 @@ Type Designer
obj.Clear()
+ obj.AddLast(TDesShip.CreateFromLevel(level))
+
For Local o:Object=EachIn level.grav
obj.AddLast(TDesGrav.CreateFromLevel(o))
Next
@@ -544,19 +647,21 @@ Type Designer
Function EditLevelSettings()
ld_invert.checked = level.invmass
- ld_placefriend.checked = level.placefriend
- ld_maxmass.text = level.maxmass
+ ld_wrap.checked = level.wrap
+ ld_maxwave.text = level.maxwave
ld_winpercent.text = level.winpercent
ld_timer.text = level.timer
- ld_placemass.SetFloat(level.placemass)
+ ld_shipmass.SetFloat(level.shipmass)
+ ld_wavemass.SetFloat(level.wavemass)
If GUIDialog(ldialog,ld_ok,ld_cancel,GameGFX.pointer)
level.invmass = ld_invert.checked
- level.placefriend= ld_placefriend.checked
- level.maxmass = ld_maxmass.text.ToInt()
+ level.wrap = ld_wrap.checked
+ level.maxwave = Min(MAX_WAVE,ld_maxwave.text.ToInt())
level.winpercent = Max(0,Min(100,ld_winpercent.text.ToInt()))
level.timer = ld_timer.text.ToInt()
- level.placemass = ld_placemass.text.ToDouble()
+ level.shipmass = ld_shipmass.text.ToDouble()
+ level.wavemass = ld_wavemass.text.ToDouble()
EndIf
End Function
End Type
@@ -624,14 +729,23 @@ Function DoDesigner()
If KeyHit(KEY_MOUSERIGHT)
If sel<>Null
- 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
+ If sel.removable
+ 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
+ Select GUIMenu("Object Menu",["Edit","Snap to grid"],x,y,GameGFX.pointer)
+ Case 0
+ sel.Edit()
+ Case 1
+ sel.Snap()
+ End Select
+ EndIf
Else
Select GUIMenu("Create Menu",["Create Gravity Point","Create Particle Line","Edit Level Settings"],x,y,GameGFX.pointer)
Case 0
@@ -697,8 +811,6 @@ Function TestCallback(w:TWidget)
While res<>TGame.LEVEL_FINISHED And res<>TGame.LEVEL_CANCELLED
Cls
res=g.Play()
- SetColor(255,255,255)
- DrawImage(GameGFX.pointer,MouseX(),MouseY())
FlushMem
Flip
Wend
@@ -716,34 +828,32 @@ Function CheckCallback(w:TWidget)
Designer.level.CreatePlayfield(m,p)
- If m.Count()+Designer.level.maxmass>MAX_GRAV
+ If (m.Count()+1)>MAX_GRAV
ok=False
- s:+"|Too many masses (combining placed and dropped)"
+ s:+"| * Too many masses (combining placed and ship)"
EndIf
- Local friends:Int=(Designer.level.placefriend And Designer.level.maxmass>0)
+ Local friends:Int=False
- If Not friends
- For Local gp:TMass=EachIn m
- If gp.friend
- friends=True
- EndIf
- Next
- EndIf
+ For Local gp:TMass=EachIn m
+ If gp.friend
+ friends=True
+ EndIf
+ Next
If Not friends
ok=False
- s:+"|No collector masses (no particles can be captured by player)"
+ s:+"| * No collector masses (no particles can be captured by player)"
EndIf
If p.Count()>MAX_POINT
ok=False
- s:+"|Too many points (" + p.Count() + " -- maximum is " + MAX_POINT
+ s:+"| * Too many points (" + p.Count() + " -- maximum is " + MAX_POINT + ")"
EndIf
If p.Count()=0
ok=False
- s:+"|No particles to collect!"
+ s:+"| * No particles to collect"
EndIf
If Not ok