Got to level 12 but no further. It's surprisingly addictive!
Haven't done any game programming recently so I thought I'd have a go at a *very* basic BlitzMax version I knocked up in about an hour... I'm very rusty, so the code isn't very clean or optimised, but I'd thought I'd share it anyway...
Updated version including shakes and better stats.
I'm sure that someone will be able to improve it. Btw, is this kind of thing legal - replicating someone else's idea in a game? If not, I'll remove the code immediately.
Cheers
Seb
Haven't done any game programming recently so I thought I'd have a go at a *very* basic BlitzMax version I knocked up in about an hour... I'm very rusty, so the code isn't very clean or optimised, but I'd thought I'd share it anyway...
Updated version including shakes and better stats.
SuperStrict Framework BRL.GLMax2D Import BRL.Math Import BRL.Random Import BRL.Timer Import BRL.EventQueue Import BRL.LinkedList AppTitle = "Dot Fury!" Graphics 640,480,0 Global gfxInit% = 1;SeedRnd MilliSecs();SetBlend LIGHTBLEND AddHook EmitEventHook,TBlob.EventHandler TBlob.AdvanceLevel() Repeat Select WaitEvent() Case EVENT_APPTERMINATE;End Case EVENT_KEYDOWN;If EventData() = KEY_ESCAPE Then End EndSelect Forever Type TBlob Global tmrUpdate:TTimer = CreateTimer(30) Global lstBlobs:TList = New TList, lstExploding:TList = New TList Global valLevel% = 0, valCount% = -1, valScore% = 0, valShake# = 0 Const blastradius% = 50 Field x%, y%, growth# = 1.5 Field direction%[2] Field color%[3] Field radius# = 10 Function AddBlob:TBlob() Local tmpBlob:TBlob = New TBlob tmpBlob.x = Rand(0,GraphicsWidth());tmpBlob.y = Rand(0,GraphicsHeight()) While tmpBlob.Dead();tmpBlob.direction[0] = Rand(-3,3);tmpBlob.direction[1] = Rand(-3,3);Wend tmpBlob.color[0] = Rand(0,255);tmpBlob.color[1] = Rand(0,255);tmpBlob.color[2] = Rand(0,255) lstBlobs.AddLast tmpBlob Return tmpBlob EndFunction Function DrawBlobs() SetOrigin(Rand(-valShake,valShake),Rand(-valShake,valShake)) For Local tmpBlob:TBlob = EachIn lstBlobs tmpBlob.Draw() Next SetOrigin(0,0) SetAlpha 1.0 SetColor 255,255,255 DrawText "Level " + valLevel,0,0 DrawText "Score: " + valScore,0,GraphicsHeight()-TextHeight(" ") If valCount >= valLevel Then SetColor 0,255,0 DrawText Max(valCount,0) + "/20",GraphicsWidth()-TextWidth(Max(valCount,0) + "/20"),GraphicsHeight()-TextHeight(" ") EndFunction Function UpdateBlobs() If lstExploding.Count() = 0 Then If valCount >= valLevel Then valScore:+valCount AdvanceLevel() ElseIf valCount >= 0 Then valLevel:-1;AdvanceLevel() EndIf EndIf For Local tmpBlob:TBlob = EachIn lstBlobs tmpBlob.Update() Next valShake:*0.5 For Local tmpBlob:TBlob = EachIn lstExploding tmpBlob.Explode() For Local tmpTestBlob:TBlob = EachIn lstBlobs If Not tmpTestBlob.Dead() And Sqr((tmpTestBlob.x - tmpBlob.x)^2 + (tmpTestBlob.y - tmpBlob.y)^2) <= (tmpBlob.radius + tmpTestBlob.radius) Then tmpTestBlob.Detonate() Next Next EndFunction Function DoMouseBlob() If valCount >=0 Then Return Local blbMouse:TBlob = AddBlob();blbMouse.x = MouseX();blbMouse.y = MouseY();blbMouse.color[0]=255;blbMouse.color[1]=255;blbMouse.color[2]=255;blbMouse.Detonate();valShake=0 EndFunction Function EventHandler:Object( id%, data:Object, context:Object ) Select TEvent(data).id Case EVENT_TIMERTICK If gfxInit And TTimer(TEvent(data).source) = tmrUpdate Then Cls TBlob.UpdateBlobs();TBlob.DrawBlobs() Flip Return Null EndIf Case EVENT_MOUSEDOWN If TEvent(data).data = 1 Then TBlob.DoMouseBlob();Return Null EndSelect Return data EndFunction Function AdvanceLevel() ClearBlobs();valLevel:+1;valCount = -1 For Local i% = 0 Until 20;TBlob.AddBlob();Next EndFunction Function ClearBlobs() lstBlobs.Clear();lstExploding.Clear() EndFunction Method Explode() If radius <= 0 Then Remove() Else radius:+growth;growth:-0.04 EndMethod Method Dead%() Return (direction[0] = 0 And direction[1] = 0) EndMethod Method Detonate() direction[0] = 0;direction[1] = 0 If Not lstExploding.Contains(Self) Then lstExploding.AddLast Self;valCount:+1;valShake = 15 EndMethod Method Draw() If Dead() Then SetAlpha radius/blastradius Else SetAlpha 1 SetColor color[0],color[1],color[2] DrawOval(x-radius,y-radius,radius*2,radius*2) EndMethod Method Update() If x < radius Then direction[0] = Abs(direction[0]) ElseIf x+radius > GraphicsWidth() Then direction[0] = -Abs(direction[0]) If y < radius Then direction[1] = Abs(direction[1]) ElseIf y+radius > GraphicsHeight() Then direction[1] = -Abs(direction[1]) x:+direction[0];y:+direction[1] EndMethod Method Remove() lstBlobs.Remove Self lstExploding.Remove Self EndMethod EndType
I'm sure that someone will be able to improve it. Btw, is this kind of thing legal - replicating someone else's idea in a game? If not, I'll remove the code immediately.
Cheers
Seb