summaryrefslogtreecommitdiff
path: root/level.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'level.bmx')
-rw-r--r--level.bmx34
1 files changed, 22 insertions, 12 deletions
diff --git a/level.bmx b/level.bmx
index 50411a1..ba0ea40 100644
--- a/level.bmx
+++ b/level.bmx
@@ -7,9 +7,10 @@
Strict
Import noddybox.vector
Import noddybox.bitmapfont
+Import noddybox.algorithm
Import "types.bmx"
-Const MAGIC:String="$Version$"
+Const MAGIC:String="PPINCH0.0"
Const MAX_GRAV:Int=10
Const MAX_POINT:Int=1000
@@ -17,9 +18,6 @@ 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
@@ -74,12 +72,11 @@ Type TGravPoint
End Type
Type TPointLine
- Field mode:Int
Field x1:Float
Field y1:Float
Field x2:Float
Field y2:Float
- Field num:Int
+ Field gap:Int
Field v:TVector
Method New()
@@ -87,28 +84,41 @@ Type TPointLine
End Method
Method CreatePoints(l:TList)
+ Local line:TList=DoLine(x1,y1,x2,y2)
+ Local n:Int=line.Count()
+ Local i:Int=0
+
+ For Local p:TAlgoPoint=EachIn line
+ If (i Mod gap)=0
+ Local tp:TPoint=New TPoint
+ tp.x=p.x
+ tp.y=p.y
+ tp.v.x=v.x
+ tp.v.y=v.y
+ l.AddLast(tp)
+ EndIf
+ i:+1
+ Next
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.gap=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(gap)
s.WriteInt(v.x)
s.WriteInt(v.y)
End Method
@@ -192,7 +202,7 @@ Type TLevelSet
name="Untitled"
End Method
- Function FromStream:TLevelSet(file:String)
+ Function Load:TLevelSet(file:String)
Local s:TStream=ReadStream(file)
If s=Null
@@ -221,7 +231,7 @@ Type TLevelSet
Return o
End Function
- Method ToStream:Int(file:String)
+ Method Save:Int(file:String)
Local s:TStream=WriteStream(file)
If s=Null