Section 6

Next Steps Towards Deployment

We have some hooks in place that provide a way to have our Laser Game morph be the visible morph in the Squeak world. And the existing code handles correct centering when someone re-sizes the main Squeak window. We can probably tighten all of that up but let's push onwards closer to a stand-alone Laser Game application.

The concept here is that we will continue to develop with the existing Squeak image and also make a new second Squeak image for the deployed application. There will then be two Squeak images as far as our Laser Game development efforts is concerned. And they should behave differently. The development image will be exactly as we have been operating so far and the deployed image will always launch with our game running in "full world" mode. Also, we want to do everything we can to disable user access to the regular Squeak menus and other development facilities when running the deployed image.

Let's begin by changing a few methods on our LaserGame class. I want to modify the #fullWorld: class method. It's not a "code" change. I just want to change the comment to set the value to "true" instead. This seems like a more helpful setup.

fullWorld: aBoolean
    "LaserGame fullWorld: false"
    FullWorld := aBoolean

Next we will add two new class methods to LaserGame. These "worker" methods are useful for launching the game in either the full world or standard mode.

launchStandard
    "LaserGame launchStandard"
    | morph |
    self fullWorld: false.
    morph := self new.
    morph openInHand.
    ^morph

launchFullWorld
    "LaserGame launchFullWorld"
    | morph |
    self fullWorld: true.
    morph := self new.
    morph openInWorld.
    ^morph

When we attempt to restrict the user's access to standard Squeak actions that should include disabling the Command-. (Command Period) capability. Currently, when a user performs a Command-. Squeak will drop into the debugger. This is obviously something we will curtail.

As it turns out, there's a Preference we can set in our progamming that enables and disables this capability. We will design things so that the launched application will have this feature disabled. That means we can detect the presence of the feature being disabled or not to know if we are running a development mode.

Add the following instance method to LaserGame.

quitGameExitSqueakCheck
    "Use the Preferences cmdDotEnabled as an indicator that we are run-time or not."
    Preferences cmdDotEnabled ifFalse: [Smalltalk quitPrimitive]

When this method is called if we detect that command-dot is disabled, we assume we are not in the developer image. You'll see how we use this next. Add another new instance method to LaserGame.

quitGameAction
    self delete.
    self class fullWorld ifTrue: [self class fullWorld: false].
    self quitGameExitSqueakCheck

When we call this method we are expecting to perform a game quit action. We delete/close the morph and then if we find we are in full world mode we turn that off. That's just a handy thing we will use as we develop. Most importantly we then call the #quitGameExitSqueakCheck method which we already saw would cause Squeak to exit if this is the non-development image.

Now we modify the existing #xxx LaserGame instance method to utilize this sequence.

quitGame
    (self confirm: 'Are you sure you want to quit?') ifTrue: [self quitGameAction]

The way we have this designed, unless we disable command-. in our development image, the Quit action of our game will act essentially as it always is. It will have the additional behavior of exiting Squeak if this is the deployed image.

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels    stevewessels@me.com