f) Exit screen
Here we are already, at the final part of the tutorial…
See file ‘2 - exitscreen.bmx’
We’re not going to go to town on this one. We’re not even going to load any resources. Just a simple message to the player, or actually, a simple message to you congratulating you on reaching the end of the first tutorial!
As usual we will define a new type that extends AppModule with a Create function and Start, FadeOutComplete, Update and Draw methods. Here it is..
Type exitScreen Extends AppModule
Function Create()
Local es:exitScreen = New exitScreen
es.Initialise( “”, APP_OUTRO )
End Function
Method FadeOutComplete()
EndModule()
End Method
Method Start()
Super.Start()
FlushMouse()
End Method
Method Update( timeMS:Int )
Super.Update( timeMS )
If ( MouseHit( 1 ) And (Not IsFading()) )
SetFadeColor( 255, 255, 255 )
StartFadeOut()
End If
End Method
Method Draw()
SetColor( 255, 255, 255 )
SetScale( 1, 1 )
GuiDrawText( “CONGRATULATIONS YOU HAVE COMPLETED THE FIRST”, 40, 100 )
GuiDrawText( “mbmFramework TUTORIAL!”, 200, 130 )
SetColor( 255, 0, 0 )
SetScale( 1.5, 1.5 )
GuiDrawText( “CLICK MOUSE TO EXIT”, 180, 300 )
Super.Draw()
End Method
End Type
I’m not even going to explain it in detail because it’s so simple. It’s only doing one thing we’ve not done before - that’s flushing the mouse keys (or buttons) during the Start method. Since I use MouseHit to decide when to leave, it’s possible (indeed, more than likely!) that the mouse hit that clicked the GUI exit button will trigger this module to quit as soon as it arrived. So flushing the mouse (and all control really) when a module starts is good practice.
Creating an exitScreen object can go with the other module creation functions..
exitscreen.Create()
Voila! A complete game application. Let’s review what we’ve got for what little coding we’ve had to do…
- An animated intro
- Application flow — from an intro to the main menu, to and from the game, and from the main menu to the outro
- User options — A dialog with volume controls and a fullscreen toggle button
- High scores
- Player login
- Persistant data — All our high scores and options are saved between sessions
- Resource management — We just defined the resources in text files, then let the framework load and unload them for us.
- Sprite instances — Multitudes of animated and non-animated sprites managed in SpriteLists
- A funky GUI — Complete with glowing buttons and fancy animated window transitions
- Particle effects
Of course, some of the resources such as the GUI forms and buttons were already provided but that’s still a lot of functionality for a first test - and there’s more to come! There’s not much more needed before you have a very high quality game on your hands.
An idea of what’s to come includes:
- Learning how to customise the GUI
- Adding a pause menu and loading screens
- Utlising the automagic loading progress
- Encrypting the application data file
- Using the resource files for setting game variables
- Using the locale for multi-lingual games
I hope you’ve enjoyed this first tutorial and I look forward to doing some more soon!
