Prepare For Application Deployment
What will we need to do if we want our Laser Game to be a stand-alone application written in Squeak? The overall concept is that we will ensure that only our game morph is open on the screen. Since the user has the ability to resize the Squeak World we need to make it look as if the only "window" visible is our game morph regardless of size.
Let's add the capability of making our Laser Game behave as if it's the only morph in the Squeak World. We will do this by first adding a "flag" we can use to tell us when we want to run in Full World. That is, when we will be the only object visible.
Open up a class hierarchy browser on LaserGame. Ensure you have no methods selected. We're going to modify the existing class definition. We will add a new Class Variable named "FullWorld". Save this change in the class definition.
Morph subclass: #LaserGame
instanceVariableNames: 'grid boardForm activeCellLocation dirty moves'
We will write accessing methods for this new class variable. Make it so the default condition is "false". Here are the new class methods for the LaserGame class.
"LaserGame fullWorld: true"
FullWorld := aBoolean
I added a comment statement in the method. If we click once inside the double-quotes that define the comment, adjacent to and inside by one of the double-quotes, the code inside the comment will be selected. We could then execute that little snippet of code when we need to set the value to True.
FullWorld isNil ifTrue: [self fullWorld: false].
Now we make changes to instance methods on LaserGame. Change this method first.
| targetForFill |
self class fullWorld
self color: Color transparent.
targetForFill := World
self color: (Color r: 0.369 g: 0.369 b: 0.505).
targetForFill := self
targetForFill fillWithRamp: self windowColorRamp oriented: firstname.lastname@example.org
We're checking if the Full World flag is set. If not, we do what we have done before. The temporary variable "targetForFill" is used for the fill statement at then end of the method. When we are not in a Full World situation, that target is the Laser Game morph.
However, when the Full World flag is set, we want to get the entire world and fill it with our color ramp. And if we change our own color to be transparent it looks like we are part of one very large morph now.
This is just one step in getting all this work. But let's see how it works. If you have a LaserGame morph open, close it. First we should just open up a LaserGame morph to ensure it all still looks and works the same. Click on some mirror cells and fire the laser to quickly check it out.
Before we open our LaserGame morph in a full world mode, we should open up a Workspace window and use the following code to launch our morph.