6.3.5 Cmu Cs Academy [upd] • Genuine & Recent

The CMU CS Academy 6.3.5 exercise typically focuses on continuous movement and collision detection in Python. Depending on your specific curriculum edition, the problem usually asks you to implement a moving object—like a DVD screensaver or a Boat in Ball Pool—that bounces off the edges of the canvas. 🚀 6.3.5: Movement Logic Report

In this lesson, you are tasked with moving a Group or shape continuously using the onStep function. 1. Initialize Movement Variables

You must first define how fast the object moves by adding custom properties to your object, often called dx (change in x) and dy (change in y). icon.dx = 5 icon.dy = 5 2. Move the Object

Inside the onStep() function, you update the object's position by adding these dx and dy values to its current center coordinates. icon.centerX += icon.dx icon.centerY += icon.dy 3. Implement Boundary Bouncing

To keep the object on the screen, you check if its edges have hit the canvas boundaries (0 to 400). If it hits a wall, you multiply the movement variable by -1 to reverse the direction.

Horizontal Bounce: If icon.right >= 400 or icon.left <= 0, then icon.dx *= -1.

Vertical Bounce: If icon.bottom >= 400 or icon.top <= 0, then icon.dy *= -1. 💡 Common 6.3.5 Variants

DVD Screensaver: Focuses on reversing direction and sometimes changing the color of the label when it hits a corner.

Boat in Ball Pool: Requires the boat to stay within the boundaries while potentially interacting with other moving objects.

Triforce: An older variant that involves manipulating polygon positions and rotation based on their location on the screen.

In CMU CS Academy's curriculum, Section 6.3.5 typically involves a "Creative Task" or a specific "Honors/Advanced" exercise that challenges students to apply Unit 6 concepts functions, and custom shape properties for animation.

While exercise titles can vary slightly by edition (e.g., "DVD Screensaver," "Triforce," or "Boat in Ball Pool"), they all focus on automated motion collision logic Core Concepts of Section 6.3.5 6.3.5 Cmu Cs Academy

This section is the "practical application" phase for the following Unit 6 skills:

: Storing multiple shapes in one variable to move or rotate them as a single unit.

: A function called automatically by the program (defaulting to 30 times per second) to create animations without user input. Custom Properties (

: Using non-standard properties to store the horizontal and vertical speed of a group or shape. Boundary Checking statements inside to check if a group's has hit the edge of the 400x400 canvas. Example: "DVD Screensaver" Solution (6.3.5)

A common version of this exercise requires an "icon" group to bounce off the walls of the screen. Initialize the Group and Speed Create a group and assign it custom speed properties. = Group( Rect( ), Label( ) ) icon.dx = # Speed in x direction # Speed in y direction Use code with caution. Copied to clipboard Apply Motion in Update the position by adding the speed values every step. (): icon.centerX += icon.dx icon.centerY += icon.dy # Check for horizontal bounce (icon.right >= icon.left <= ): icon.dx *= - # Check for vertical bounce (icon.bottom >= icon.top <= ): icon.dy *= - Use code with caution. Copied to clipboard Success Tips for Unit 6.3.5 Check Your Groups : Ensure all individual shapes are added to your Group variable before the function begins. Use the Inspector : If your bounce logic is off by a few pixels, use the CS Academy Inspector

to find the exact coordinates where the shape hits the edge. Indentation Matters

: Remember that any code intended to run repeatedly must be indented inside the def onStep():

CMU CS Academy exercise 6.3.5 focuses on mastering procedural animation using the onStep function to manipulate multiple shapes, such as in the "Triforce" or "Continuous Cartwheels" variants. The core logic involves utilizing onStep to update shape properties—including centerX, centerY, and rotateAngle—to create smooth, animated motion. Detailed solutions and explanations for this exercise can be found at Course Hero Course Hero.

Since CMU CS Academy updates their curriculum frequently and specific exercise numbers can shift, Unit 6.3 generally focuses on Keyboard Input. Specifically, 6.3.5 is typically an exercise where students learn to move a shape using onKeyPress and onKeyRelease to create smooth movement (handling the "sticky key" issue).

Below is a guide on the concepts taught in this section and a walkthrough for a standard "Shape Mover" exercise.


The Objective: From Text to Graphics

The primary goal of 6.3.5 is to bridge the gap between backend data processing and frontend visual output. Students are usually tasked with reading a CSV (Comma Separated Values) file and plotting the data using a Bar Chart, Line Graph, or Scatter Plot. The CMU CS Academy 6

This exercise reinforces the idea that coding is a tool for problem-solving. Instead of just drawing shapes, students are drawing shapes based on external, real-world variables.

Step-by-Step Solution for 6.3.5

Here is a complete, commented solution that will pass the 6.3.5 CMU CS Academy autograder:

# 6.3.5 - Moving Circle with Arrow Keys
# CMU CS Academy Solution

Challenge 1: "My shape moves once and stops!"

Cause: You put the movement code inside onKeyPress instead of onStep. Fix: onKeyPress should only toggle a variable (app.moving = True). The actual coordinate change (shape.centerX += 5) must go inside onStep.

Tips for Success in CMU CS Academy

To excel at checkpoints like 6.3.5, follow these strategies:

  • Read the prompt twice. CMU CS Academy prompts are precise; miss one word and your solution fails the auto-grader.
  • Draw on paper first. Sketch the grid and color indices before writing code.
  • Use print statements. Insert print(grid) after the inner loop to debug row by row.
  • Check variable scope. Ensure new_row is reinitialized as an empty list for each outer loop iteration.
  • Test edge cases. What if rows = 1? What if cols = 1? What if rows = 0?

Troubleshooting Common Errors

If you are currently stuck on 6.3.5, check for these common pitfalls:

  • Header Rows: Did you forget to skip the first row of the CSV? If your code tries to turn a text header into a number, it will crash. Use next(reader) to skip headers.
  • Data Types: Remember that CSV files read everything as strings. You must convert numbers using int() or float() before graphing.
  • Indentation: Ensure your graphing command (Chart.bar) is not inside the for loop. You want to graph the completed lists, not redraw the chart for every single row.

The goal of the 6.3.5 "Click to Create Star" exercise in CMU CS Academy is to create a program where a star appears at the exact location where the user clicks their mouse. Solution Code

def onMousePress(mouseX, mouseY): # This creates a star with 5 points and a radius of 20 # at the (x, y) coordinates of the mouse click. Star(mouseX, mouseY, 20, 5, fill='gold') Use code with caution. Copied to clipboard 1. Identify the Trigger

The exercise requires an action to happen when the user interacts with the canvas. In CMU CS Academy, the onMousePress function is a built-in "event listener" that automatically runs whenever the mouse button is clicked. 2. Capture Coordinates

The function onMousePress(mouseX, mouseY) provides two built-in variables: mouseX: The horizontal position of the click.

mouseY: The vertical position of the click.These variables act as the "anchor" for where your shape will be drawn. 3. Draw the Shape

Inside the function, you call the Star inspector. By passing mouseX and mouseY as the first two arguments, you ensure the star's center aligns with the tip of the mouse cursor. Syntax: Star(centerX, centerY, radius, points) The Objective: From Text to Graphics The primary goal of 6

Customization: You can change the fill, radius, or number of points to match the specific visual requirements of your assignment (e.g., fill='yellow' or points=8). ✅ Final Result

The final code uses the onMousePress event to dynamically instantiate a Star object at the specific coordinates provided by the user's input. If you'd like to add more features to this write-up: Should the stars change color each time? Do they need to disappear when a key is pressed?


Declare global variable for the circle

circle = None

def onAppStart(app): global circle # Create blue circle at center of 400x400 canvas circle = Circle(200, 200, 20, fill='blue') # Add it to the canvas add(circle)

def onKeyPress(key): global circle # Movement speed speed = 15

# Arrow key logic
if key == 'up':
    if circle.centerY - speed >= 20:  # Keep within top edge
        circle.centerY -= speed
elif key == 'down':
    if circle.centerY + speed <= 380: # Keep within bottom edge
        circle.centerY += speed
elif key == 'left':
    if circle.centerX - speed >= 20:  # Keep within left edge
        circle.centerX -= speed
elif key == 'right':
    if circle.centerX + speed <= 380: # Keep within right edge
        circle.centerX += speed

Note: The boundary check uses 20 and 380 because the radius is 20. The center of a 20px radius circle at x=20 touches the edge at x=0.

Implementation Outline (Python for CMU CSA)

from cmu_graphics import *
import random

trail = []

def onMouseDrag(mouseX, mouseY): # Add a new circle at the mouse position with random color circle = Circle(mouseX, mouseY, 8) circle.fill = rgb(random.randint(100,255), random.randint(100,255), random.randint(100,255)) circle.opacity = 60 trail.append(circle)

def onKeyPress(key): if key == 'space': # Remove all trail circles from the canvas for circle in trail: circle.visible = False trail.clear()

def onStep(): # Optional: fade or shrink old trail points pass

4. Common Challenges & Fixes