| ' ---------------------MAIN LOOP------------------------- Repeat Cls UpdateGameState() For Local o:TGameObject=EachIn GameObjectList o.DrawSelf() o.UpdateSelf() Next Flip Forever End |
| Function UpdateGameState() Select GameState Case PLAY If KeyDown(KEY_ESCAPE) Or AppTerminate() End EndIf EndSelect EndFunction |
| ' -----------------SETUP GAME CONDITIONS-------------------- Const PLAYER_LAYER:Int=1 Const PLAY:Int=1 Global GameState:Int=PLAY |
| Type TText Extends TGameObject Field Text:String Field Font:TImageFont Function Create:TText(Text:String, Font:TImageFont,xstart:Int,ystart:Int) Local B:TText=New TText B.Text=Text B.Font=Font B.X=XStart B.Y=YStart ListAddLast GameObjectList, B Return B End Function Method UpdateSelf() 'DO NOTHING End Method Method drawself() SetImageFont(Font) SetRotation 0 SetScale 1.0,1.0 DrawText Text,X,Y End Method EndType |
| Function UpdateGameState() Select GameState Case PLAY If KeyDown(KEY_ESCAPE) Or AppTerminate() TText.Create("PRESS <ENTER> To RE-START",Font,80,250) TText.Create("PRESS ESCAPE TO EXIT",Font,80,300) FlushKeys() GameState=PAUSE EndIf Case PAUSE If KeyDown(KEY_ESCAPE) Or AppTerminate() End EndIf If KeyDown(KEY_ENTER) GameState=PLAY '-------------Remove all of the Text Objects For Local o:TText=EachIn GameObjectList ListRemove(GameObjectList,o) Next EndIf FlushKeys() EndFunction |
| Local FontURL:String="http::www.2dgamecreators.com/tutorials/gameprogramming/breakout/" Global Font:TImageFont=LoadImageFont(FontURL+"BorisBlackBloxx.ttf",24) |
| Const PLAY:Int=1 Const PAUSE:Int=2 |
| Method UpdateSelf() If GameState<>PLAY Then Return |
![]() |