diff options
Diffstat (limited to 'game.bmx')
-rw-r--r-- | game.bmx | 112 |
1 files changed, 75 insertions, 37 deletions
@@ -10,12 +10,12 @@ Import noddybox.bitmapfont Import "types.bmx" Import "level.bmx" -Const LEVEL_NOTOVER:Int= 0 -Const LEVEL_WON:Int= 1 -Const LEVEL_LOST:Int= 2 - Type TGame + Const LEVEL_NOTOVER:Int= 0 + Const LEVEL_WON:Int= 1 + Const LEVEL_LOST:Int= 2 + Field level:TLevel Field mass:TList Field point:TList @@ -31,6 +31,8 @@ Type TGame Field col:Int Field coli:Int + Field final_percent:Int + Function Create:TGame(level:TLevel) Local o:TGame=New TGame @@ -43,19 +45,21 @@ Type TGame o.done=LEVEL_NOTOVER o.frame=0 o.placed=0 - o.txtoff=[GameGFX.font.TextWidth("PARTICLES"),GameGFX.font.TextWidth("CAPTURED"),GameGFX.font.TextWidth("LOST"),GameGFX.font.TextWidth("TIMER")] + o.txtoff=[GameGFX.font.TextWidth("PARTICLES"),GameGFX.font.TextWidth("CAPTURED"),GameGFX.font.TextWidth("TIMER")] o.playing=False o.col=0 - o.coli=1 + o.coli=5 + o.final_percent=0 Return o End Function Method Intro() Local y:Int=GraphicsHeight()/4 Local yi:Int=25 + col:+coli - If col=255 Or col=128 + If col=255 Or col=0 coli=-coli EndIf @@ -64,55 +68,84 @@ Type TGame GameGFX.font.CentreColoured(level.name,y,col,col,255-col) y:+yi - GameGFX.font.CentreColoured("Need "+level.winpercent+"% to clear",GraphicsHeight()/2,col/2,col,col) + GameGFX.font.CentreColoured("Need "+level.winpercent+"% to clear",y,col/2,col,col) y:+yi - GameGFX.font.CentreColoured("You can place "+level.maxmass+" masses",GraphicsHeight()/2,col/2,col,col) + GameGFX.font.CentreColoured("You can place "+level.maxmass+" masses",y,col/2,col,col) y:+yi - If level.invmass + If level.invmass GameGFX.font.CentreColoured("PLACED MASSES ARE INVERTED!",y,col,col/2,col/2) y:+yi EndIf + If level.placefriend + GameGFX.font.CentreColoured("PLACED MASSES ARE COLLECTORS!",y,col,col/2,col/2) + y:+yi + EndIf + + y:+yi + GameGFX.font.Centre("Press Left Mouse Button",y) + y:+yi + SetScale(1,1) End Method Method Play:Int() captured=0 lost=0 - - For Local m:TMass=EachIn mass - For Local s:TPoint=EachIn point - s.Attract(m) + + If playing + For Local m:TMass=EachIn mass + For Local s:TPoint=EachIn point + s.Attract(m) + Next Next - Next + EndIf TParticleMachine.Process() - For Local m:TMass=EachIn mass - m.MoveAndDraw() - Next + If playing + For Local m:TMass=EachIn mass + m.Move() + m.Draw() + Next + Else + For Local m:TMass=EachIn mass + m.Draw() + Next + EndIf + + If playing + For Local s:TPoint=EachIn point + s.Move() + s.Draw() + + If s.dead + captured:+1 + ElseIf s.lost + lost:+1 + EndIf + Next + Else + For Local s:TPoint=EachIn point + s.Draw() + Next + EndIf - For Local s:TPoint=EachIn point - s.MoveAndDraw() + If playing And done=LEVEL_NOTOVER + frame:+1 - If s.dead - captured:+1 - ElseIf s.lost - lost:+1 + If frame=60 And timer>0 + frame=0 + timer:-1 EndIf - Next - - frame:+1 - - If frame=60 And timer>0 - timer:-1 EndIf Local percent:Int=Int(Float(captured)/Float(num)*100.0) - If (timer=0 Or num=0) And done=LEVEL_NOTOVER + If (timer=0 Or num=captured+lost) And done=LEVEL_NOTOVER + final_percent=percent If percent>=level.winpercent done=LEVEL_WON Else @@ -122,17 +155,20 @@ Type TGame GameGFX.font.Draw("PARTICLES",0,0) GameGFX.font.DrawColoured(num-captured-lost,txtoff[0]+10,0,255,255,0) + GameGFX.font.Draw("CAPTURED",200,0) - GameGFX.font.DrawColoured(percent+"%",txtoff[1]+210,0,255,0,255) - GameGFX.font.Draw("LOST",400,0) - GameGFX.font.DrawColoured((100-percent)+"%",txtoff[2]+410,0,255,0,0) + If done=LEVEL_NOTOVER + GameGFX.font.DrawColoured(percent+"%",txtoff[1]+210,0,255,0,255) + Else + GameGFX.font.DrawColoured(final_percent+"%",txtoff[1]+210,0,255,0,255) + EndIf GameGFX.font.Draw("TIMER",600,0) If timer>10 - GameGFX.font.Draw(timer,txtoff[3]+610,0) + GameGFX.font.Draw(timer,txtoff[2]+610,0) Else - GameGFX.font.DrawColoured(timer,txtoff[3]+610,0,255,0,0) + GameGFX.font.DrawColoured(timer,txtoff[2]+610,0,255,0,0) EndIf Select done @@ -141,12 +177,14 @@ Type TGame If placed<level.maxmass And mass.Count()<MAX_GRAV If MouseHit(1) Local m:TMass=New TMass - m.friend=False + m.friend=level.placefriend m.inverse=level.invmass m.x=MouseX() m.y=MouseY() m.img=GameGFX.mass + m.mass=level.placemass mass.AddLast(m) + placed:+1 EndIf EndIf Else |