Difference between revisions of "IB Computer Science 1"
From WLCS
Line 30: | Line 30: | ||
** You must not allow a move to occur in a space that already has a move | ** You must not allow a move to occur in a space that already has a move | ||
− | + | == [[IBCS1 - 1920 - September]] == | |
− | + | == [[IBCS1 - Archives]] == | |
− |
Revision as of 10:30, 4 October 2019
Friday (10/4/19)
Agenda:
- Group 4 Project - field trip slips
- Complete and demo Tic-Tac-Toe: Part 2 (see description from Wednesday)
- If you have completed Tic-Tac-Toe: Part 2, then proceed to adding conditionals to determine winning
- Don't forget about cat's games (tie-game) where the board is completely full
Wednesday (10/2/19)
Agenda:
- Demonstrate Tic-Tac-Toe Select-a-Square
- Read text() and test out its example code snippet
- You can use text() to draw X and O on the screen for our game!
- Read global variables and test out its example code snippet in Processing
- You will interact with the code snippet by hitting keys
- Focus on understanding the use of the global keyword
- Read mouseReleased() and test out its example code snippet in Processing
- You will interact with the code snippet by pressing and releasing the mouse/trackpad button
- The mouseReleased() function automatically runs every time the mouse's button is released
- What components of Tic-Tac-Toe are left?
- Copy your Tic-Tac-Toe code to a new Processing sketch program and save it as TTT_Part2
- Declare/create a global string variable named turn and initialize it to either "X" or "O"
- Declare/create global variables for each square in the game (e.g. b_0_0, b_0_1) -- you will use these variables to track where moves are made
- Initialize all the b_#_# variables to empty strings ""
- Define the mouseReleased() function like the example linked above. Read all of the following guidelines for mouseReleased()
- You will add/modify the mouseReleased() code block, such that you will determine where the mouse is releasing (using if-statements), and then you will change/update the corresponding b_#_# variable
- You can use the same if statements and conditionals from the previous "select-a-square" lab! (i.e. copy all your if-statements from the draw() and paste them into mouseReleased(). You will not need any of the fill() or rect() in mouseReleased()
- If a particular square is clicked, then save the current player's turn into that specific b_#_#
- Update your draw() so that all of the b_#_# variables are text()-ed onto the screen at their appropriate locations
- Every time you release the mouse and draw "X" or "O", the turn should switch
- You must not allow a move to occur in a space that already has a move