For this programming assignment, you are given a rudimentary version of Simon for Squeak and asked to add features to it. You will extend it to do the following:
Keep Score: Attach a numerical indicator that shows how far into the sequence the user has made it.
Time-outs: In the original Simon, you have a limited amount of time to press a button or the game is lost. The version of Simon provided below does not implement the time-out. You will add it.
Player Says: The version of Simon available for you below basically implements Game 1 (Simon Says). You will add Game 2 (Player Says) as a possibility. Don't worry about Game 3 (Choose Your Color); that will be part of Programming Assignment 2.
The Squeak Simon
Figure 1: Simon (Green Button Pressed)
To use the Squeak Simon, first download the code and install it. To file in the code, open a file list (World Menu::open...::file list), find and select the Simon-initial.st file; click the filein button to install the code. This should create a new category (cs2340-Simon) in the System Browser with the Simon code. To open a new Simon game, execute SimonGame newAsMorph.
The Simon version included uses a paradigm for object-oriented user interfaces that is quite common. It separates the model (what the application does) from the view (how the application looks). None of the three classes included are visual elements that you see on the display. Instead, the visual elements are standard pluggable widgets that provide the view for their models (both SimonGame and SimonButton are subclasses of Model). For example, each visual button is a PluggableButtonMorph that has the corresponding SimonButton as its model. Check out these three methods in the SimonButton to see how button flashing is implemented:
asMorph - This is the method where the PluggableButtonMorph is created. Notice that the getState: is set to #isLighted.
flash - This is the method that flashes the button using the isLighted: method.
isLighted: - When self changed: #isLighted happens, the view (the PluggableButtonMorph) updates how it looks, because of how it was created in the asMorph method above.
When you see something with a # before it, that's a Symbol. Symbols can be used to have arbitrary execution happen at any time. someObject perform: #aMessage is the same as someObject aMessage. Pluggable interfaces use that to determine values. A PluggableButtonMorph determines its label, menu, and action it is to do when pressed based on symbols.
You do not have to separate the model and the view to write UI code in Squeak's Morphic interface; however, it is generally good object-oriented practice to do so. The programming assignments were designed to give you some first-hand experience with this paradigm. The intention is that you learn how to write user interfaces in this manner and see the benefits and drawbacks of this technique over a more ad hoc approach.
Keep Score (20)
The score is well integrated into the game - 10
Score works for different levels - 10
The time-outs work as expected - 20
The time allowed per move is shorter in more difficult levels - 10
Player Says (50)
You can play Player Says - 30
You can choose whether to play Simon Says or Player Says - 5
You can choose which level to play for Player Says - 5
The score keeps working for Player Says - 5
The time-outs keep working for Player Says - 5
You are not allowed to share your code with others in this class. You can give or receive incidental help (but not code) from others. This is an individal assignment; you turn in your own code. The only exception to this rule is if you want to complete this assignment using pair programming (read this page if you are interested).