{"author_name":"MrPhil","cat":"LD #13 - Roads - 2008","comments":[],"epoch":1228507320,"likes":0,"metadata":{"p_key":"74439","p_author":"MrPhil","p_authorkey":"165","p_urlkey":"110271","p_title":"Count Me In","p_cat":"LD #13 - Roads - 2008","p_event":"LD13","p_time":"1228507320","p_likes":"0","p_comments":"0","p_status":"UPD5","us_key":"165","us_name":"MrPhil","us_username":"mrphil","event_start":"1228435200","event_key":"92","event_name":"LD13"},"text":"<p>I&#8217;ve decided to enter again.\u00a0 This will be Ludum Dare number 4 for me.\u00a0 This time I&#8217;m planning to use <a title=\"BlitzMax\" href=\"http:\/\/blitzmax.com\/Home\/_index_.php\" target=\"_blank\">BlitzMax<\/a> and Jake Birkett&#8217;s <a title=\"Grey Alien BlitzMax Game Framework\" href=\"http:\/\/www.greyaliengames.com\/framework.php\" target=\"_blank\"><span class=\"maintitle\">Grey Alien BlitzMax Game Framework<\/span><\/a>.\u00a0 Here is the basic setup code I&#8217;ll be using (if you follow the &#8220;Start Here&#8221; document this should be your result, except I added a try-catch around everything for unhandled exceptions):<span id=\"more-3697\"><\/span><\/p>\n <p>SuperStrict<\/p>\n <p>?Win32<br \/>\n Import &#8220;..\/include\/fullaccess.cpp&#8221;<br \/>\n Import &#8220;-ladvapi32&#8221;<br \/>\n ?<\/p>\n <p>&#8216;Import various Mac OS API calls made in C.<\/p>\n <p>?MacOS<br \/>\n Import &#8220;..\/include\/GAGMacLib.m&#8221;<br \/>\n ?<\/p>\n <p>Include &#8220;..\/include\/commoncode.bmx&#8221;<br \/>\n Include &#8220;..\/include\/commontypes.bmx&#8221;<\/p>\n <p>Try<\/p>\n <p>ccCreateMutex(&#8220;BasicSetup&#8221;)<\/p>\n <p>AppTitle = &#8220;BasicSetup&#8221;<\/p>\n <p>ScreenWidth = 800<br \/>\n ScreenHeight = 600<\/p>\n <p>Game = New TGame<br \/>\n Game.SetSubPathWrapper(&#8220;Grey Alien Games\/Basic Setup&#8221;)<br \/>\n Game.Init()<br \/>\n Game.DebugDisplayX = 5<br \/>\n Game.DebugDisplayY = 95<br \/>\n Game.SetEscapeSound(&#8220;ButtonClick&#8221;)<\/p>\n <p>Global images:TImageBank = New TImageBank<br \/>\n images.SetPath(Game.ImagePath)<br \/>\n Global sounds:TSoundBank = New TSoundBank<br \/>\n sounds.SetPath(Game.SoundPath)<\/p>\n <p>&#8216;Instance both types that we created<br \/>\n Global TitleScreen: TTitleScreen = New TTitleScreen<br \/>\n Global GameScreen: TGameScreen= New TGameScreen<\/p>\n <p>Game.GraphicsCreate() &#8216;Create a graphics context<br \/>\n HideMouse &#8216;hide the mouse<br \/>\n LoadData() &#8216;load data using a function we will define<br \/>\n ccFlushAll() &#8216;flush keys and mouse<\/p>\n <p>Local LoopExit:Int = 0 &#8216;boolean for exiting the main loop<br \/>\n Game.FixedRateLogic.Init()<br \/>\n Game.NoTimingTicks = 3 &#8216;only applied if Game.NoTiming=1<\/p>\n <p>Repeat<br \/>\n &#8216;do the logic separately from the drawing<br \/>\n If Game.MainLogicLoop() = -1 Then ShutDown()<br \/>\n &#8216;draw the screen and flip it to show it<br \/>\n Game.ScreenDraw()<br \/>\n Until LoopExit = 1<br \/>\n ShutDown()<\/p>\n <p>Function Shutdown()<br \/>\n Tgame.MakeGoodExit()<br \/>\n ShowMouse() &#8216;just in case it was hidden.<br \/>\n &#8216;Exit the program<br \/>\n End<br \/>\n End Function<\/p>\n <p>&#8216;Instance both types that we created<\/p>\n <p>Function LoadData()<br \/>\n AutoMidHandle True<br \/>\n ccClsVSync()&#8217;Ensure clear screen when loading<\/p>\n <p>LoadSounds()<br \/>\n LoadImages()<br \/>\n TitleScreen.Load() &#8216;Call load method of TitleScreen<br \/>\n TitleScreen.Start() &#8216;Call start method of TitleScreen<br \/>\n &#8216;Now loading is complete, let the main loop handle the drawing<br \/>\n Game.CurrentTScreen = TitleScreen<\/p>\n <p>?Win32 &#8216;Has the app been suspended while loading? If so, deal with it.<br \/>\n If GetForegroundWindow()&lt;&gt;Game.WindowHandle<br \/>\n Game.SuspendedEvent = 1<br \/>\n EndIf<br \/>\n ?<br \/>\n End Function<\/p>\n <p>Function LoadSounds()<br \/>\n sounds.Load(&#8220;ButtonClick&#8221;) &#8216;load the sound &#8220;buttonclick&#8221;<br \/>\n End Function<\/p>\n <p>Function LoadImages()<br \/>\n Game.mouse.Load(&#8220;pointer&#8221;) &#8216;load mouse pointer image<br \/>\n images.Load(&#8220;Paused&#8221;) &#8216;Load &#8220;paused&#8221; graphic<br \/>\n &#8216;Create Paused sprite<br \/>\n Game.SpritePausedCreate(Images.Find(&#8220;Paused&#8221;))<br \/>\n End Function<\/p>\n <p>Type TTitleScreen Extends TScreen<br \/>\n Field x#,y#<\/p>\n <p>Method Load()<br \/>\n &#8216;this is a TScreen method<br \/>\n ImageLoad(&#8220;title.jpg&#8221;,FILTEREDIMAGE)<br \/>\n MidHandleImage(Image)<br \/>\n &#8216;this gets midhandled automatically<br \/>\n HeaderLoad(&#8220;logolarge&#8221;,screenwidth\/2,100)<br \/>\n Menu = TMenu.Create(&#8220;ButtonMO&#8221;, &#8220;ButtonClick&#8221;,0,0,10)<br \/>\n &#8216;Add a new Button<br \/>\n &#8216;Allow Space and Enter to trigger it<br \/>\n Menu.AddNew(&#8220;playgame&#8221;, &#8220;playgameMO&#8221;).OKButton = 1<br \/>\n Menu.AddNew(&#8220;exitgame&#8221;,&#8221;exitgameMO&#8221;)<br \/>\n Menu.Centre() &#8216;Center the Menu<br \/>\n &#8216;Move the Y position of the menu<br \/>\n Menu.SetY(Menu.Y+50)<br \/>\n End Method<\/p>\n <p>Method Start()<br \/>\n Super.Start() &#8216;Call Start method of base type TScreen<br \/>\n Game.GameFade.Init(FADE_SPEED,0) &#8216;fade in<br \/>\n Game.Mouse.On()<br \/>\n Game.FixedRateLogic.Init()<br \/>\n End Method<\/p>\n <p>Method Logic()<br \/>\n &#8216;Call the logic method of the base type<br \/>\n Super.Logic()<br \/>\n &#8216;If the start button is clicked, fade to the next screen<br \/>\n &#8216;and set that next screen to the GameScreen<br \/>\n If Menu.FindButton(&#8220;playgame&#8221;).Clicked Then<br \/>\n Game.GameFade.Init(FADE_SPEED,1,Game.MusicChannel, True)<br \/>\n Game.DestinationTScreen = GameScreen<br \/>\n EndIf<\/p>\n <p>&#8216;If the exit button is clicked, fade the screen and exit<br \/>\n If Menu.FindButton(&#8220;exitgame&#8221;).Clicked Then<br \/>\n Game.GameFade.Init(FADE_SPEED,1,Game.MusicChannel, True)<br \/>\n Game.DestinationTScreen = Game.ExitScreen<br \/>\n EndIf<br \/>\n End Method<\/p>\n <p>Method Draw()<br \/>\n SetBlend SOLIDBLEND<br \/>\n &#8216;Image is a field of the base type TScreen<br \/>\n DrawImage(Image,screenwidth\/2+x,screenheight\/2+y)<br \/>\n SetBlend ALPHABLEND<br \/>\n Header.Draw() &#8216;Draw the logo that we loaded earlier<br \/>\n Menu.Draw() &#8216;Draw the Menu<br \/>\n End Method<br \/>\n End Type<\/p>\n <p>Type TGameScreen Extends TScreen<\/p>\n <p>Method Load()<br \/>\n ImageLoad(&#8220;bg1.jpg&#8221;)<br \/>\n HeaderLoad(&#8220;logosmall&#8221;,210,35)<br \/>\n End Method<\/p>\n <p>Method Start()<br \/>\n Super.Start()<br \/>\n Game.GameFade.Init(FADE_SPEED,0) &#8216;initiate fading<br \/>\n Game.Mouse.Off() &#8216;Turn the mouse off<br \/>\n Game.FixedRateLogic.Init()<br \/>\n End Method<\/p>\n <p>Method Logic()<br \/>\n Super.Logic() &#8216;handles menu core logic<br \/>\n End Method<\/p>\n <p>Method Draw()<br \/>\n Cls<br \/>\n SetBlend ALPHABLEND<br \/>\n DrawImage(image,0,0)<br \/>\n Header.Draw() &#8216;Draw the header<br \/>\n SetColor 255,255,255<br \/>\n &#8216;Draw instructional text<br \/>\n ccDrawTextCentre(&#8220;Press &lt;esc&gt; to Exit&#8221;,560,1)<br \/>\n End Method<\/p>\n <p>Method SetEscDestination() &#8216;over ride base type method<br \/>\n &#8216;if esc is pressed, go to the TitleScreen<br \/>\n Game.DestinationTScreen = TitleScreen<br \/>\n End Method<br \/>\n End Type<\/p>\n <p>Catch ex:Object<\/p>\n <p>Print &#8220;Unhandled exception:&#8221;<br \/>\n Print ex.ToString()<\/p>\n <p>End Try<\/p>\n \n <p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/mrphil\/\" rel=\"tag\">MrPhil<\/a><\/p>","time":"December 5th, 2008 3:02 pm","title":"Count Me In"}