diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-09-03 01:27:08 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-09-03 01:27:08 +0000 |
commit | 740fa42f8b879759e5feaa02ea4cbe405c2e97ff (patch) | |
tree | 5e315b404332f2d2405c53b9028cba4a67c39beb | |
parent | fd9c6b4263213f46af51747f39d8a206d46ee295 (diff) |
Initial import
-rw-r--r-- | .cvsignore | 2 | ||||
-rw-r--r-- | GFX/button.png | bin | 0 -> 3490 bytes | |||
-rw-r--r-- | GFX/font.bmf | bin | 0 -> 24420 bytes | |||
-rw-r--r-- | main.bmx | 155 | ||||
-rw-r--r-- | types.bmx | 129 |
5 files changed, 286 insertions, 0 deletions
diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..953a728 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,2 @@ +main.debug.exe
+.bmx
\ No newline at end of file diff --git a/GFX/button.png b/GFX/button.png Binary files differnew file mode 100644 index 0000000..6e78c3a --- /dev/null +++ b/GFX/button.png diff --git a/GFX/font.bmf b/GFX/font.bmf Binary files differnew file mode 100644 index 0000000..38378e6 --- /dev/null +++ b/GFX/font.bmf diff --git a/main.bmx b/main.bmx new file mode 100644 index 0000000..1a2646b --- /dev/null +++ b/main.bmx @@ -0,0 +1,155 @@ +' It's all a bit rolly +' +Strict + +Import noddybox.vector +Import noddybox.bitmapfont + +' Includes +' +Include "types.bmx" + + +' Included binaries +' +Incbin "GFX/font.bmf" + + +' Initialise graphics +' +SetGraphicsDriver GLMax2DDriver() +Graphics 800,600,32,60 +'HideMouse + +SetBlend(ALPHABLEND) + +' Globals +' +Global font:TBitmapFont=TBitmapFont.Load("incbin::GFX/font.bmf",0) + +' Consts +' + +' 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.g=100 +main_mass.b=100 +main_mass.inverse=True + +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) + +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 + + 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() + mass.AddLast(m) + EndIf + + 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 + +EndGraphics +End
\ No newline at end of file diff --git a/types.bmx b/types.bmx new file mode 100644 index 0000000..322d863 --- /dev/null +++ b/types.bmx @@ -0,0 +1,129 @@ +' It's all a bit rolly +' +Global MASSSIZE:Int=4 +Global MASSRAD:Int=MASSSIZE/2 + +Type TMass + Field x:Float + Field y:Float + Field v:TVector + Field r:Int + Field g:Int + Field b:Int + Field mass:Float + Field friend:Int + Field inverse:Int + + Method New() + v=TVector.Create() + x=Rnd(0,GraphicsWidth()) + y=Rnd(0,GraphicsWidth()) + r=255 + g=255 + b=255 + mass=25 + friend=True + inverse=False + End Method + + Method Attract(o:TMass) + If o=Self + Return + EndIf + + Local d:TVector=TVector.Create(o.x-x,o.y-y) + Local l:Float=d.Length() + + If l>0.1 + l:*l + d.Normalise() + d.Scale((1/l)*o.mass) + + If o.inverse + d.Minus() + EndIf + + v.Add(d) + + If d.Length()>MASSSIZE + d.SetLength(MASSSIZE) + EndIf + EndIf + End Method + + Method MoveAndDraw() + x:+v.x + y:+v.y + SetColor(r,g,b) + DrawOval(x-MASSRAD,y-MASSRAD,MASSSIZE,MASSSIZE) + End Method +End Type + + +Type TPoint + Field x:Float + Field y:Float + Field v:TVector + Field r:Int + Field g:Int + Field b:Int + Field dead:Int + Field lost:Int + + Method New() + v=TVector.Create() + x=Rnd(0,GraphicsWidth()) + y=Rnd(0,GraphicsWidth()) + r=Rand(100,200) + g=Rand(100,200) + b=Rand(100,200) + dead=False + lost=False + End Method + + Method Attract:Int(o:TMass) + If dead Or lost + Return + EndIf + + Local d:TVector=TVector.Create(o.x-x,o.y-y) + Local l:Float=d.Length() + + If l<MASSRAD + If o.friend + dead=True + Else + lost=True + EndIf + Else + l:*l + d.Normalise() + d.Scale((1/l)*o.mass) + + If o.inverse + d.Minus() + EndIf + + v.Add(d) + + If d.Length()>MASSSIZE + d.SetLength(MASSSIZE) + EndIf + EndIf + + Return dead + End Method + + Method MoveAndDraw() + If (Not dead) And (Not lost) + x:+v.x + y:+v.y + SetColor(r,g,b) + Plot(x,y) + + If x<0 Or y<0 Or x>GraphicsWidth() Or y>GraphicsHeight() + lost=True + EndIf + EndIf + End Method +End Type |