CISC 124 Assignment 3 --------------------- Here's a game without much purpose. You can move tiles around on a grid and make a ball move through them. Each tile has a passage through which the ball can pass; some passages are straight and others are curved. You can drag tiles with the mouse. You can also type these keys: 'g' start or stop the ball ('g' for 'go') 'r' reverse the ball '+' speed up the ball '-' slow down the ball The initial set of tiles is defined in a board configuration file called 'initialBoard'. The file looks like c r t11 t12 t13 ... t1c t21 t22 t23 ... t2c t31 t32 t33 ... t3c ... ... ... ... ... tr1 tr2 tr3 ... trc where c and r and the x dimension (columns) and y dimension (rows), respectively, and txy is the tile in cell (x,y). A tile can be one of hz horizontal vt vertical ul elbow in upper-left corner ur elbow in upper-right corner lr elbow in lower-right corner ll elbow in lower-left corner - no tile Note that any cell can have a hyphen '-' to indicate that no tile is initially placed in that cell. See the files 'initialBoard' and 'initialBoard2' for some examples. Step 1 ------ Get the program running. Try the 'initialBoard'. Here's a challenge: Start the ball rolling by pressing 'g'. Then quickly rearrange the pieces while the ball is moving so that the ball loops around continuously. If you're too slow, the ball will get stuck. You can restart it by pressing 'g' again (you might have to reverse it first, by pressing 'r'). This challenge is easier is you've got a slow computer. Look at the code and understand it at a high level. You should understand how the events get handled, and how the tiles are stored. But you don't need to know how the tiles are drawn, or exactly how the ball is moved through them. Step 2 ------ Make the following changes: A. Add GUI buttons that have the same functionality as the 'g', 'r', '+', and '-' keys described above. B. Modify the code so that the Piece (i.e. tile) currently occupied by the ball is highlighted in a different colour. You should store the Piece colour with the Piece, and change it when the ball enters the Piece. Modify the Piece::draw() method to use the correct colour. Update your colours in the Board.moveBall() method, where it says "YOUR CODE HERE". Add a checkbox to your GUI to allow the highlighting to be turned on or off. C. Modify the game so that it becomes a puzzle. The puzzle is to get the ball to move from a start tile to a goal tile. Add an Blocker Piece which extends the Piece class. A Blocker is drawn as a solid tile. This is done already by the Piece class, so you don't need to do any graphics calls. The Blocker should not be movable, so you'll need to add an 'immovable' flag to the base Piece class, and take that into account when the mouse is pressed. This can be done with a single extra line of code in the mousePresseed() method. Modify the PieceList class to include Blocker pieces, which are denoted with a capital 'B' in the board configuration file. The ball can't pass through a Blocker, so you don't need to handle any ball movement. Add two more Pieces: a Start and a Goal. Each Piece should extend one of the horizontal StraightPieces, so you don't won't need do any graphics or handle the ball movement. You'll have to initially position the ball in middle of the Start piece, if a Start piece exists. Both Start and Goal pieces are immovable. They are denoted as 'S' and 'G' in the board configuration file. Show a message in your GUI when the ball reaches the Goal. Step 3 ------ We will have a contest, separately within each of the two sections of CISC 124, for the best additional modifications to the tile program. The best modifications will be shown in class, and a small prize will be awarded in each section of CISC 124. You do not have to enter the contest; you can get full marks on this assignment if you only complete Step 2. Here are some ideas for additional modifications. Don't let this list limit your imagination! - Provide a timer to show how fast the player gets from the start to the goal. The timer would count up in *real* time from the time the player starts the ball, to the time the ball reaches the goal. - Make this into a construction game by providing another panel from which new pieces can be created. For example, you might drag a piece from that other panel into your main panel. Pieces in that other panel would be 'replenished' immediately. - (Challenging) Create new pieces. For example, create a crossover piece which allows the ball to move through it horizontally *or* vertically. Or create a 'random' piece which has an empty interior and which directs the ball to a random exit. If you want to play with graphics, add an animated mechanism inside the piece and have the mechanism move as the ball passes through. - Make certain pieces hide the ball as it passes through them. With this feature, you could cluster some of these hiding pieces. The player would have to deduce what pieces are inside the cluster by sending the ball into the cluster and seeing where it comes out ... from several different entry points. Providing crossover and random pieces makes the puzzle harder. Submit with your code a CONTEST_README file that explains what modifications you made. In that file (which should be plain text) describe why your modifications are interesting, difficult, fun, or whatever.