Difference between revisions of "IB Computer Science 1"

From WLCS
Line 11: Line 11:
 
*#* Example: text(b_0_0, 100, 100)
 
*#* Example: text(b_0_0, 100, 100)
 
*#* Test your code out at this point by giving some of the board (b) variables starting values of "X" or "O" -- be sure to revert them back to empty strings when done with testing
 
*#* Test your code out at this point by giving some of the board (b) variables starting values of "X" or "O" -- be sure to revert them back to empty strings when done with testing
*# Define mouseReleased() like the X-O clicker assignment.  Add/modify the code, so that you detect where the click/release is occurring, and you draw a text "X" or an "O" in the appropriate place. Hint: You can use the same if statements or conditional from the previous lab!
+
*# Define mouseReleased() like the X-O clicker assignment.  Add/modify the code, so that you detect where the click/release is occurring, and change the appropriate board (b) variable to store the move (turn). Hint: You can use the same if statements or conditionals from the select-a-square lab!
 
*#* You should be sure to save the appropriate move in the board (b) variables
 
*#* You should be sure to save the appropriate move in the board (b) variables
 
*#* Every time you release the mouse and draw "X" or "O", the turn should switch
 
*#* Every time you release the mouse and draw "X" or "O", the turn should switch

Revision as of 16:01, 16 October 2018

Wednesday (10/17/18)

Agenda:

  • text() and textSize() notes
  • X-O clicker assignment
    • Modify the code of the mouseReleased() so that a text-based X or O is drawn every time the mouse button is released
  • Tic-Tac-Toe: Part 2
    1. At the very top of your code, declare/create a global string variable named turn and initialize it to either "X" or "O"
    2. At the very top of your code, 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
    3. Copy your setup() and draw() from your Tic-Tac-Toe: Select-a-Square
    4. At the end of draw(), add text() commands that draw all the board (b) variables in their respective locations
      • Example: text(b_0_0, 100, 100)
      • Test your code out at this point by giving some of the board (b) variables starting values of "X" or "O" -- be sure to revert them back to empty strings when done with testing
    5. Define mouseReleased() like the X-O clicker assignment. Add/modify the code, so that you detect where the click/release is occurring, and change the appropriate board (b) variable to store the move (turn). Hint: You can use the same if statements or conditionals from the select-a-square lab!
      • You should be sure to save the appropriate move in the board (b) variables
      • 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 (check the appropriate board (b) variable to make sure the corresponding slot is still empty string)

Thursday - Monday (10/11/18 - 10/15/18)

Agenda:

  • 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
    • Define the mouseReleased() function like the example linked above. Add/modify the mouseReleased() code block, so that you draw a either ax "X" or an "O" in the corresponding slot. Hint: You can use the same if statements or conditional from the previous lab!
    • 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

Wednesday (10/10/18)

  • PSATs

Friday (10/6/18)

Agenda:

  • Introduction to Animation
    • setup() function
    • draw() function
    • mouseX and mouseY variables
    • width and height variables
  • Tic-Tac-Toe Select-a-Square
    1. Setup your screen size to be a large square (e.g. 600x600)
    2. Within the draw() function, give the background a color()
    3. Draw tic-tac-toe lines on your screen (make sure that the rows and columns are exactly 1/3 the size of the height and width)
    4. Add conditional statements in the draw() function to detect which square you are in
      • You'll need to access the mouse's current coordinates with mouseX and mouseY variables
      • Draw a square of a different color inside the particular square that you are in
      • The effect that you will generate will look like it is highlighting the current square where the mouse is
    5. Challenge: Modify your code so that changing the screen size, will automatically be adjusted and accounted for by the rest of your code. Hint: use height and width variables
    6. Challenge 2: Modify your code so that it works without any conditionals. Hint: use division and multiplication
  • Coming soon...
    • Functions
    • Global variables
    • Mouse clicks

Wednesday (10/3/18)

Agenda:

  • Complete and demo Introduction: My First Sketch
  • Processing review
    • size()
    • rect()
    • ellipse()
    • line()
    • background()
    • fill()
    • stroke()
  • Draw and demo your favorite emoji / logo / cartoon character using Processing before the end of class

Monday (10/1/18)

Warmup:

  • Take the Conditionals Quiz in Canvas

Agenda:

Archives