Lab 28

Graphics: Positions, Units, and Defaults

CS211 Lab Policy:

Instructions:

For this lab you will modify a graphical tick-tack-toe program, lab28.m. This program allows a user to play tick-tack-toe on a graphical board and select the next move using mouse clicks. The Lab28() program is fully functional and you can play tick-tack-toe without any modifications to the file. Your task is to make it more "exciting" by generating motion after the game finishes. You can download and execute an example of this lab assignment, lab28p.p.

Your assignment is to add code to the 4 functions at the end of the file as described below:

To complete the function Display_winner(Board_size, Winning_player)

  1. Calculate the center of the Board. Use the equation   1 + (Board_size / 2). This works for both the vertical and horizontal axis directions.
     
  2. Use the text() function and the input argument Winning_player (which has a value of 'X', 'O', or 'C') to display a message that says who won the game. The message should be displayed exactly in the middle of the axes object. Make the text size large (set 'FontSize' to 72) and use the 'HorizontalAlignment' and 'VerticalAlignment' properties to center the text.
     

To complete the function O_won()

  1. Set the 'Units' property of the axes object to 'normalized'.
     
  2. Get the current location of the axes object. (Use the 'Position' property.) The value that is returned will be a 4-element row vector containing the values [x_offset y_offset axes_width axes_height] in normalized units.
     
  3. Repeat the following 20 times: (This will make the axes object "shutter" up and down.)
  4. Set the 'Position' property of the axes object back to its original value.
     

To complete the function X_won()        (Copy and paste the code from O_won() and change appropriately.)

  1. Set the 'Units' property of the axes object to 'normalized'.
     
  2. Get the current location of the axes object. (Use the 'Position' property.) The value that is returned will be a 4-element row vector containing the values [x_offset y_offset axes_width axes_height] in normalized units.
     
  3. Repeat the following 20 times: (This will make the axes object "shutter" back and forth.)
  4. Set the 'Position' property of the axes object back to its original value.
     

To complete the function Cat_won()        (Copy and paste the code from O_won() and change appropriately.)

  1. Set the 'Units' property of the axes object to 'normalized'.
     
  2. Get the current location of the axes object. (Use the 'Position' property.) The value that is returned will be a 4-element row vector containing the values [x_offset y_offset axes_width axes_height] in normalized units.
     
  3. Repeat the following until the axes object is no longer visible: (This will make the axes object slide down the figure and out of sight.)

Turn-in:

Submit your Lab28.m file.