Difference between revisions of "IB Computer Science 1"

From WLCS
(31 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Friday (11/2/18) ==
+
== Wednesday - Friday (12/5/18 - 12/7/18) ==
'''Agenda:'''
 
* Misc Quiz on Canvas
 
* More advanced mouse fun
 
** Complete the table found in [https://docs.google.com/document/d/1wfVoej_7PVHquaAcugEr5YWZIzbKPNl8YYKlp7Gfouo/edit?usp=sharing Mouse Variables & Functions]
 
** Complete the Part 2 activity in [https://docs.google.com/document/d/1wfVoej_7PVHquaAcugEr5YWZIzbKPNl8YYKlp7Gfouo/edit?usp=sharing Mouse Variables & Functions]
 
* Fancy Buttons
 
*# Create 4 buttons on the screen of some color of your choice (use the same color for all 4 buttons)
 
*# Hovering over a button changes its color shade darker and increases the stroke weight around that particular button
 
*# Pressing the button makes the color shade even darker (darker than hover)
 
*# Releasing the button should return it to its original color.  Depending on how you create your program, you may not need to define mouseReleased()
 
* Complete [https://docs.google.com/document/d/1xRSA_Ti8l5002jcAftcUtCTdujCojghzoTpUZwJvHQ4/edit?usp=sharing Bouncing Ball]
 
* We will be working on creating a simple pool program that uses the mouse to control hitting a ball to hit another ball
 
 
 
== Wednesday (10/31/18) ==
 
 
'''Agenda:'''
 
'''Agenda:'''
* Quiz on Friday (11/2/18)
+
* Be sure you have turned in your game design document to Canvas
** Variables
+
** Game Requirements (Dinosaur OR Flappy Bird) assignment
** Conditions
+
* Missing demos:
** if statements
+
** [https://docs.google.com/document/d/13zLTnm_mxURSFxEWJ24MUBOAK1Y6jbfk8NxL-wS_U7g/edit?usp=sharing Loading & Displaying Images]
** functions
+
* Gravity / Jumping review with images
* Demo any missing assignments
+
* Rectangular collision detection
** [https://docs.google.com/document/d/1i6iUV20KXDF_yKr4mn5X4JQQPc4hF7lklkp5DlDpMCE/edit?usp=sharing Functions: Hover Buttons] is the last assignment of the quarter
+
* Individually work on your game - some collaboration is fine
* More advanced mouse fun
+
* Subjectively graded progress check on Tuesday (12/11/18)
** Complete the table found in [https://docs.google.com/document/d/1wfVoej_7PVHquaAcugEr5YWZIzbKPNl8YYKlp7Gfouo/edit?usp=sharing Mouse Variables & Functions]
+
** You should be able to discuss the progress that you have made and the obstacles that you have encountered
** Complete the Part 2 activity in [https://docs.google.com/document/d/1wfVoej_7PVHquaAcugEr5YWZIzbKPNl8YYKlp7Gfouo/edit?usp=sharing Mouse Variables & Functions]
+
** Game should be completed and demo-able by the end of Thursday (12/13/18)
* Fancy Buttons
 
*# Create 4 buttons on the screen of some color of your choice (use the same color for all 4 buttons)
 
*# Hovering over a button changes its color shade darker and increases the stroke weight around that particular button
 
*# Pressing the button makes the color shade even darker (darker than hover)
 
*# Releasing the button should return it to its original color.  Depending on how you create your program, you may not need to define mouseReleased()
 
 
 
<!-- BROKEN
 
* Complete and demo [https://docs.google.com/document/d/1g5aP7hBogJYCDSdURtG0SfG3CY-q7aLtYyGilZaQcSM/edit?usp=sharing Media: Loading & Playing Sounds]
 
* Sound Board Project
 
*# Create a completely new Processing project called Sound Board
 
*# You will use your experience from the [https://docs.google.com/document/d/1i6iUV20KXDF_yKr4mn5X4JQQPc4hF7lklkp5DlDpMCE/edit?usp=sharing Hover Buttons] and [https://docs.google.com/document/d/1g5aP7hBogJYCDSdURtG0SfG3CY-q7aLtYyGilZaQcSM/edit?usp=sharing Sound Lab] to design and create a sound board
 
*# Download 6 school-appropriate sound clips of your favorite TV/movie character
 
*# Design and implement your 6 of your own buttons in your program. The buttons must have text on them indicating the sound each will play.  The buttons must also highlight when you hover over them
 
*# When you press a button, there should be a quick animation like a color change to indicate the button was hit.
 
*# Also when you press a button, play the appropriate sound that corresponds to the button's label
 
*# Your program should define and call functions whenever it is most appropriate
 
-->
 
  
== Monday (10/29/18) ==
+
== Monday (12/3/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* Demo Tic-Tac-Toe: Function Assignment (if you did not get to demo last class)
+
* Group 4 Project Debrief
* Demo [https://docs.google.com/document/d/1u1aQNdF_V-_n_zE5gAbMbjh45IHNyrX4P4sCDzldvKs/edit?usp=sharing Functions: Emoji Assignment]
+
* [https://goo.gl/forms/0ya5UJ6KdVJvDvJF3 Group 4 Project Reflection Google Form]
* Complete and demo [https://docs.google.com/document/d/1i6iUV20KXDF_yKr4mn5X4JQQPc4hF7lklkp5DlDpMCE/edit?usp=sharing Functions: Hover Buttons]
+
** Complete this form even if you already turned in a PDF
* Work on the challenges in either of the above assignments
+
** You may copy the reflection that you wrote in your PDF and paste it into the form
 +
* Missing demos can be shown today or in GP
 +
** Basic Pool: Part 2
 +
** Keyboard Practice
  
== Thursday (10/25/18) ==
+
* Complete [https://docs.google.com/document/d/13zLTnm_mxURSFxEWJ24MUBOAK1Y6jbfk8NxL-wS_U7g/edit?usp=sharing Loading & Displaying Images]
'''Warmup:'''
+
* Class discussion - Chrome Dinosaur Game OR Flappy Bird
* Complete repl.it warmup: "Warmup 10/25/18"
+
*# Which game would you like to design and develop?
* Complete repl.it assignment: "Function definitions & return"
+
*# With a partner, open a Google Doc and share the Google Doc with the partner so both of you have write access
 +
*# Place both of your names at the top of the document
 +
*# List all the requirements of your chosen game with brief descriptions for each (e.g. Arrow key movement - pressing the arrow keys moves the dinosaur forward / backward)
 +
*# Under each of the requirements, place a sub-bullet that briefly describes the programming technique / construct that you will probably use to implement that feature (e.g. score will be kept tracked by using a variable that increases over time)
 +
*# Both students should submit the document to Canvas
 +
*# Prepare to share your document with the rest of the class
 +
* Begin individually developing your Dinosaur or Flappy Bird game
  
 +
== Thursday (11/29/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* Group 4 project permission slips
+
* Most students will be attending the Group 4 Project field trip
* Demo your completed Tic-Tac-Toe: Part 3
+
* If you are not attending, go to Ms. Miller's room (#3003)
* Functions review
+
* Work on any missing assignments
* Complete Tic-Tac-Toe: Function Assignment '''today'''
 
*# Go back to your Tic-Tac-Toe code and look for redundant blocks of code. You should notice that the code that switches turns occurs in several places
 
*# Define a new function called switchTurn(), and move your code that switches turns into that function definition
 
*# Replace all the redundant blocks of code with function calls to switchTurn()
 
*# Re-test your Tic-Tac-Toe program to make sure that it still works
 
*# Demo your slimmer Tic-Tac-Toe game that uses functions
 
* Work on [https://docs.google.com/document/d/1u1aQNdF_V-_n_zE5gAbMbjh45IHNyrX4P4sCDzldvKs/edit?usp=sharing Functions: Emoji Assignment] - due next class
 
* Work on [https://docs.google.com/document/d/1i6iUV20KXDF_yKr4mn5X4JQQPc4hF7lklkp5DlDpMCE/edit?usp=sharing Functions: Hover Buttons]
 
  
== Tuesday (10/23/18) ==
+
== Tuesday (11/27/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* Group 4 Project Field Trip - Nov 28 / 29
+
* Group 4 Project Field Trip (Thursday 11/29)
** Turn in field trip slips (don't worry about teacher signatures)
+
** If you are attending, check-in and orientation at the auditorium at 8:19am
* Demo your completed Tic-Tac-Toe: Part 3
+
** If you are not attending, 1st and 5th periods, go to Ms. Miller's room (#3003)
* Introduction to Functions
+
* Workplace Readiness Skills Assessment Pre-test
** [https://docs.google.com/presentation/d/1W_kTmZH-qLbcFcueUBLw3skRXIDlAxLDdJB-y7AbeWM/edit?usp=sharing Functions slides]
+
* Demo Basic Pool: Part 2
* Complete repl.it assignment titled: "Function definitions & return" - '''due Thursday (10/25/18)'''
+
* Complete and demo [https://docs.google.com/document/d/1uWpr7pX91LzklGwR6InKvsu7M9IRn2y55xgHHq0MAcQ/edit?usp=sharing Input: Keyboard Practice]
 
+
* Gravity / Jumping walk-through
'''Homework:'''
 
* Group 4 project permission slips
 
* Repl.it - Function definitions & return
 
  
== Friday (10/19/18) ==
+
== Tuesday (11/20/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* Demo Completed Tic-Tac-Toe: Part 2
+
* Thanksgiving Assembly
* Tic-Tac-Toe - Part 3
+
* Workplace Readiness Skills Assessment Pre-test
*# Add conditionals to check if any 3 locations in a row/column/diagonal match (make sure that at least one of the locations is not equal to the empty string)
+
* Demo Basic Pool: Part 2
*# Display a text() message that indicates the winner
+
* Complete and demo [https://docs.google.com/document/d/1uWpr7pX91LzklGwR6InKvsu7M9IRn2y55xgHHq0MAcQ/edit?usp=sharing Input: Keyboard Practice]
*# Add a conditional to check if the game is a draw (tie), and display a message
+
* Gravity / Jumping walk-through?
*# To stop the stop/pause the program if there is a winner or tie, you need to create a new variable (e.g. gameOver = False)
 
*#* If the game should be over, you re-assign gameOver to True
 
*#* Within the draw() code block, add a conditional to check if gameOver is True, and if it is, then use the noLoop() command to stop the draw() animation
 
* Exhaustively test your program!
 
** Try to break your program intentionally by clicking in boxes that already have moves or by making moves after the game is over
 
  
== Wednesday (10/17/18) ==
+
== Friday (11/16/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* text() and textSize() notes
+
* 2 hour delay
* X-O clicker assignment
+
* Complete and demo Basic Pool: Part 2
** Modify the code of the mouseReleased() so that a text-based X or O is drawn every time the mouse button is released
+
** You should define as many components in functions as you can (e.g. checkCollision(), checkWin(), checkLoss(), reset())
* Tic-Tac-Toe: Part 2
 
*# At the very top of your code, declare/create a global string variable named '''turn''' and initialize it to either "X" or "O"
 
*# 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
 
*# Copy your setup() and draw() from your Tic-Tac-Toe: Select-a-Square
 
*# 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
 
*# 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 successfully make a move, draw "X" or "O", then 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) ==
+
== Wednesday (11/14/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* Read [https://py.processing.org/reference/globals.html global variables] and test out its example code snippet in Processing
+
* Complete and demo Basic Pool: Part 1
** You will interact with the code snippet by hitting keys
+
* Ball Collision detection & resolution
** Focus on understanding the use of the global keyword
+
*# Use your Bouncing Ball program as a template (or you can use Basic Pool: Part 1)
* Read [https://py.processing.org/reference/mouseReleased.html mouseReleased()] and test out its example code snippet in Processing
+
*# Create two balls and make them both move around
** You will interact with the code snippet by pressing and releasing the mouse/trackpad button
+
*# Use the distance formula to detect if the two balls collide, and if they do, then paste the following code:
** The mouseReleased() function automatically runs every time the mouse's button is released
+
<syntaxhighlight lang="Python">
* What components of Tic-Tac-Toe are left?
+
# http://flatredball.com/documentation/tutorials/math/circle-collision/
** Copy your Tic-Tac-Toe code to a new Processing sketch program and save it as TTT_Part2
+
        tangentVector = PVector();
** Declare/create a global string variable named '''turn''' and initialize it to either "X" or "O"
+
        tangentVector.y = x - x2;
** 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
+
        tangentVector.x = y2 - y;
** 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!
+
        tangentVector.normalize()
** Every time you release the mouse and draw "X" or "O", the turn should switch
+
        relVel = PVector(dx-dx2, dy-dy2)
** You must not allow a move to occur in a space that already has a move
+
        velLength = relVel.dot(tangentVector)
 +
        velOnTangent = tangentVector.mult(velLength)
 +
        velPerpToTangent = relVel.sub(velOnTangent)
 +
        dx -= velPerpToTangent.x
 +
        dy -= velPerpToTangent.y
 +
        dx2 += velPerpToTangent.x
 +
        dy2 += velPerpToTangent.y
 +
        x += dx
 +
        y += dy
 +
        x2 += dx2
 +
        y2 += dy2
 +
</syntaxhighlight>
  
== Wednesday (10/10/18) ==
+
* Basic Pool: Part 2 - The player can win by shooting the pool ball into a randomly generated pocket, but loses if the cue ball ever hits the pocket.  The player will only have 3 attempts to shoot the ball in or the player loses
* PSATs
+
*# Change the color of the second ball to something non-white and non-black
 +
*# Add friction by constantly multiplying all dx and dy variables by a number between 0.9 and 1
 +
*# Create the black pocket and randomly generate its coordinates (please use variables)
 +
*# If the second ball ever collides with the pocket, then stop everything and display a winning message
 +
*# Add one of the losing condition checks -- if the cue ball (the first ball) ever collides with the pocket, then stop everything and display a losing message
 +
*# Keep track of the shots, and the player should lose when they run out of shots (start with 3).  Display the number of shots remaining at the top or bottom of the screen
 +
*# You should define as many components in functions as you can (e.g. checkCollision(), checkWin(), checkLoss(), reset())
 +
*# Challenges:
 +
*## Keep track and display points, and every time the player wins, add to the point total
 +
*## Automatically reset the game when there is a win or loss
 +
*## Add a third ball
  
== Friday (10/6/18) ==
+
== Friday (11/9/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* Introduction to Animation
+
* Demonstrate all programs
** setup() function
+
* Work on Basic Pool: Part 1 challenges
** draw() function
 
** mouseX and mouseY variables
 
** width and height variables
 
* Tic-Tac-Toe Select-a-Square
 
*# Setup your screen size to be a large square (e.g. 600x600)
 
*# Within the draw() function, give the background a color()
 
*# 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)
 
*# 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
 
*# 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
 
*# 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) ==
+
== Wednesday (11/7/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* Complete and demo [https://docs.google.com/document/d/1-TyjK48PtO_dgBDLRxKOk8zvOReC_A5196skWzCI0wk/edit?usp=sharing Introduction: My First Sketch]
+
* Mr. Bui is out b/c his son is sick. Be prepared to demonstrate all programs on Friday (11/9/18)
* Processing review
+
** Part 2 activity in [https://docs.google.com/document/d/1wfVoej_7PVHquaAcugEr5YWZIzbKPNl8YYKlp7Gfouo/edit?usp=sharing Mouse Variables & Functions]
** size()
+
** Fancy Buttons Assignment
** rect()
+
** Complete [https://docs.google.com/document/d/1xRSA_Ti8l5002jcAftcUtCTdujCojghzoTpUZwJvHQ4/edit?usp=sharing Bouncing Ball]
** ellipse()
+
* Complete Basic Pool: Part 1
** line()
+
*# Make the background green
** background()
+
*# Create a white ball on the screen with dx and dy both set to random(-10,10) so that it begins moving in a random direction
** fill()
+
*# As soon as the mouse button is pressed, make the ball stop where it is
** stroke()
+
*# While the mouse button is being held down, draw a red line from the middle of the ball to the mouse pointer
* Draw and demo your favorite emoji / logo / cartoon character using Processing before the end of class
+
*# Releasing the mouse changes the ball's velocity (dx and dy variables) using the differences between (x, y) and (mouseX, mouseY).  i.e. the larger the green line, the faster the ball should move.  If the speed is too fast, you can try shrinking the difference by dividing by 10
 
+
*# As the ball moves around the screen, it should properly bounce off the edges
== Monday (10/1/18) ==
+
*# Add a non-white second ball on the screen that is not moving, but randomly located. You can generate random numbers using [https://py.processing.org/reference/random.html random(low, high)].
'''Warmup:'''
+
*# To detect if the two balls ever collide, check the distance between their centers (x, y) and (x2, y2).  If the distance is less than the sum  of their two radii (r1 + r1), then there is a collision.  Add a collision checking if-statement that temporarily changes the fill color of the balls to red if they collide, otherwise change it back to white
* Take the Conditionals Quiz in Canvas
+
*# Challenges:  
 +
*#* Play around with stroke weight and color
 +
*#* Add friction (you'll need to create new variables) to slow down the ball
  
 +
== Friday (11/2/18) ==
 
'''Agenda:'''
 
'''Agenda:'''
* Make sure you've completed all assignments (...but how?)
+
* Misc Quiz on Canvas
* Complete & demo [[Tech Support Flow Chart Assignment]]
+
* More advanced mouse fun
* Introduction to Processing - Python Mode
+
** Complete the table found in [https://docs.google.com/document/d/1wfVoej_7PVHquaAcugEr5YWZIzbKPNl8YYKlp7Gfouo/edit?usp=sharing Mouse Variables & Functions]
*# Download and install [https://processing.org/download Processing]
+
** Complete the Part 2 activity in [https://docs.google.com/document/d/1wfVoej_7PVHquaAcugEr5YWZIzbKPNl8YYKlp7Gfouo/edit?usp=sharing Mouse Variables & Functions]
*# Install Python Mode (upper right corner)
+
* Fancy Buttons Assignment
*# [[Processing Labs]]
+
*# Create 4 buttons on the screen of some color of your choice (use the same color for all 4 buttons)
*# Complete [https://docs.google.com/document/d/1-TyjK48PtO_dgBDLRxKOk8zvOReC_A5196skWzCI0wk/edit?usp=sharing Introduction: My First Sketch]
+
*# Hovering over a button changes its color shade darker and increases the stroke weight around that particular button
* Draw and demo your favorite emoji / logo / cartoon character using Processing
+
*# Pressing the button makes the color shade even darker (darker than hover)
 +
*# Releasing the button should return it to its original color.  Depending on how you create your program, you may not need to define mouseReleased()
 +
* Complete [https://docs.google.com/document/d/1xRSA_Ti8l5002jcAftcUtCTdujCojghzoTpUZwJvHQ4/edit?usp=sharing Bouncing Ball]
 +
* We will combine our new mouse knowledge with the bouncing ball lab to create a simple pool program that uses the mouse to control hitting a ball to hit another ball
 +
*# Create a ball on the screen
 +
*# When the mouse is clicked, you should draw a green line from the middle of the ball to the mouse pointer
 +
*# Releasing the mouse changes the ball's velocity (dx, dy) using the difference between (x, y) and (mouseX, mouseY)
  
 
== Archives ==
 
== Archives ==
 +
* [[IBCS1 - 1819 - October]]
 
* [[IBCS1 - 1819 - September]]
 
* [[IBCS1 - 1819 - September]]
 
* [[IBCS1 - 1718]]
 
* [[IBCS1 - 1718]]

Revision as of 15:14, 5 December 2018

Wednesday - Friday (12/5/18 - 12/7/18)

Agenda:

  • Be sure you have turned in your game design document to Canvas
    • Game Requirements (Dinosaur OR Flappy Bird) assignment
  • Missing demos:
  • Gravity / Jumping review with images
  • Rectangular collision detection
  • Individually work on your game - some collaboration is fine
  • Subjectively graded progress check on Tuesday (12/11/18)
    • You should be able to discuss the progress that you have made and the obstacles that you have encountered
    • Game should be completed and demo-able by the end of Thursday (12/13/18)

Monday (12/3/18)

Agenda:

  • Group 4 Project Debrief
  • Group 4 Project Reflection Google Form
    • Complete this form even if you already turned in a PDF
    • You may copy the reflection that you wrote in your PDF and paste it into the form
  • Missing demos can be shown today or in GP
    • Basic Pool: Part 2
    • Keyboard Practice
  • Complete Loading & Displaying Images
  • Class discussion - Chrome Dinosaur Game OR Flappy Bird
    1. Which game would you like to design and develop?
    2. With a partner, open a Google Doc and share the Google Doc with the partner so both of you have write access
    3. Place both of your names at the top of the document
    4. List all the requirements of your chosen game with brief descriptions for each (e.g. Arrow key movement - pressing the arrow keys moves the dinosaur forward / backward)
    5. Under each of the requirements, place a sub-bullet that briefly describes the programming technique / construct that you will probably use to implement that feature (e.g. score will be kept tracked by using a variable that increases over time)
    6. Both students should submit the document to Canvas
    7. Prepare to share your document with the rest of the class
  • Begin individually developing your Dinosaur or Flappy Bird game

Thursday (11/29/18)

Agenda:

  • Most students will be attending the Group 4 Project field trip
  • If you are not attending, go to Ms. Miller's room (#3003)
  • Work on any missing assignments

Tuesday (11/27/18)

Agenda:

  • Group 4 Project Field Trip (Thursday 11/29)
    • If you are attending, check-in and orientation at the auditorium at 8:19am
    • If you are not attending, 1st and 5th periods, go to Ms. Miller's room (#3003)
  • Workplace Readiness Skills Assessment Pre-test
  • Demo Basic Pool: Part 2
  • Complete and demo Input: Keyboard Practice
  • Gravity / Jumping walk-through

Tuesday (11/20/18)

Agenda:

  • Thanksgiving Assembly
  • Workplace Readiness Skills Assessment Pre-test
  • Demo Basic Pool: Part 2
  • Complete and demo Input: Keyboard Practice
  • Gravity / Jumping walk-through?

Friday (11/16/18)

Agenda:

  • 2 hour delay
  • Complete and demo Basic Pool: Part 2
    • You should define as many components in functions as you can (e.g. checkCollision(), checkWin(), checkLoss(), reset())

Wednesday (11/14/18)

Agenda:

  • Complete and demo Basic Pool: Part 1
  • Ball Collision detection & resolution
    1. Use your Bouncing Ball program as a template (or you can use Basic Pool: Part 1)
    2. Create two balls and make them both move around
    3. Use the distance formula to detect if the two balls collide, and if they do, then paste the following code:
# http://flatredball.com/documentation/tutorials/math/circle-collision/
        tangentVector = PVector();
        tangentVector.y = x - x2;
        tangentVector.x = y2 - y;
        tangentVector.normalize()
        relVel = PVector(dx-dx2, dy-dy2)
        velLength = relVel.dot(tangentVector)
        velOnTangent = tangentVector.mult(velLength)
        velPerpToTangent = relVel.sub(velOnTangent)
        dx -= velPerpToTangent.x
        dy -= velPerpToTangent.y
        dx2 += velPerpToTangent.x
        dy2 += velPerpToTangent.y
        x += dx
        y += dy
        x2 += dx2
        y2 += dy2
  • Basic Pool: Part 2 - The player can win by shooting the pool ball into a randomly generated pocket, but loses if the cue ball ever hits the pocket. The player will only have 3 attempts to shoot the ball in or the player loses
    1. Change the color of the second ball to something non-white and non-black
    2. Add friction by constantly multiplying all dx and dy variables by a number between 0.9 and 1
    3. Create the black pocket and randomly generate its coordinates (please use variables)
    4. If the second ball ever collides with the pocket, then stop everything and display a winning message
    5. Add one of the losing condition checks -- if the cue ball (the first ball) ever collides with the pocket, then stop everything and display a losing message
    6. Keep track of the shots, and the player should lose when they run out of shots (start with 3). Display the number of shots remaining at the top or bottom of the screen
    7. You should define as many components in functions as you can (e.g. checkCollision(), checkWin(), checkLoss(), reset())
    8. Challenges:
      1. Keep track and display points, and every time the player wins, add to the point total
      2. Automatically reset the game when there is a win or loss
      3. Add a third ball

Friday (11/9/18)

Agenda:

  • Demonstrate all programs
  • Work on Basic Pool: Part 1 challenges

Wednesday (11/7/18)

Agenda:

  • Mr. Bui is out b/c his son is sick. Be prepared to demonstrate all programs on Friday (11/9/18)
  • Complete Basic Pool: Part 1
    1. Make the background green
    2. Create a white ball on the screen with dx and dy both set to random(-10,10) so that it begins moving in a random direction
    3. As soon as the mouse button is pressed, make the ball stop where it is
    4. While the mouse button is being held down, draw a red line from the middle of the ball to the mouse pointer
    5. Releasing the mouse changes the ball's velocity (dx and dy variables) using the differences between (x, y) and (mouseX, mouseY). i.e. the larger the green line, the faster the ball should move. If the speed is too fast, you can try shrinking the difference by dividing by 10
    6. As the ball moves around the screen, it should properly bounce off the edges
    7. Add a non-white second ball on the screen that is not moving, but randomly located. You can generate random numbers using random(low, high).
    8. To detect if the two balls ever collide, check the distance between their centers (x, y) and (x2, y2). If the distance is less than the sum of their two radii (r1 + r1), then there is a collision. Add a collision checking if-statement that temporarily changes the fill color of the balls to red if they collide, otherwise change it back to white
    9. Challenges:
      • Play around with stroke weight and color
      • Add friction (you'll need to create new variables) to slow down the ball

Friday (11/2/18)

Agenda:

  • Misc Quiz on Canvas
  • More advanced mouse fun
  • Fancy Buttons Assignment
    1. Create 4 buttons on the screen of some color of your choice (use the same color for all 4 buttons)
    2. Hovering over a button changes its color shade darker and increases the stroke weight around that particular button
    3. Pressing the button makes the color shade even darker (darker than hover)
    4. Releasing the button should return it to its original color. Depending on how you create your program, you may not need to define mouseReleased()
  • Complete Bouncing Ball
  • We will combine our new mouse knowledge with the bouncing ball lab to create a simple pool program that uses the mouse to control hitting a ball to hit another ball
    1. Create a ball on the screen
    2. When the mouse is clicked, you should draw a green line from the middle of the ball to the mouse pointer
    3. Releasing the mouse changes the ball's velocity (dx, dy) using the difference between (x, y) and (mouseX, mouseY)

Archives