In CMU CS Academy, exercise 6.3.5 Triforce is a programming task in Unit 6 (Groups & Motion)

that requires you to animate three triangles (polygons) using statements and property changes.

The "story" of this code is about three separate pieces of a legendary artifact moving through space and rotating until they reach their final destination. 1. Identify the shapes The program begins with three triangles named bottomLeft bottomRight

. These are grouped together or handled individually to create the iconic "Triforce" shape. 2. Animate the Top Piece You must check if the

triangle has reached its final horizontal position. If it is still to the left of the center, the code increases its angle and shifts its position both horizontally and vertically. if (top.centerX < 200): top.rotateAngle += 2 top.centerX += 2 top.centerY += 3 3. Animate the Bottom Left Piece Similarly, the bottomLeft

piece follows a specific path. It rotates and moves up and to the right until its reaches a specific threshold. if (bottomLeft.centerX < 130): bottomLeft.centerX += 3 bottomLeft.rotateAngle += 2 4. Animate the Bottom Right Piece Following the pattern of the other two, the bottomRight

piece moves into place by adjusting its rotation and position in every step until the condition is met. 5. Reaching the Final Form Because these actions are inside an

function, the shapes will appear to "glide" and "spin" into their final locked positions simultaneously, completing the Triforce story. Answer Summary The story for 6.3.5 Triforce

is a motion sequence where three individual triangles rotate and travel across the canvas using

statements to stop them exactly when they form the completed artifact. full Python solution code

for this specific exercise or help with a different Unit 6 problem?


Common Mistakes on 6.3.5

Even smart students fail 6.3.5 on the first try. Here is why:

Understanding Unit 6: Events

Unit 6 changes everything. In earlier units, code runs top-to-bottom and stops. In Unit 6, you write event handlers—functions that sit dormant until a specific action occurs.

The most important handlers for 6.3.5 are:

  • onKeyPress(key): Runs every time the user presses a key.
  • onKeyRelease(key): Runs every time the user releases a key.
  • onStep(): Runs 30 times per second (the animation loop).

Exercise 6.3.5 specifically tests your ability to use onKeyPress to manipulate object properties in real-time.

Why 6.3.5 Matters: Real-World Applications

You might wonder, "When will I ever need nested loops for a 2D grid?" The answer is: constantly. The pattern you learn in 6.3.5 is the foundation for:

  • Game Development (Minecraft grid inventories, chessboards, tile maps).
  • Image Processing (each pixel is a cell in a 2D grid of RGB values).
  • Data Science (heatmaps, confusion matrices).
  • Pathfinding Algorithms (such as A* or Dijkstra’s algorithm on a grid).

Mastering this small exercise prepares you to write more complex programs, such as Conway’s Game of Life, a tic-tac-toe AI, or a maze generator.

4. Forgetting to Return the Grid

Error: The function builds grid but does not return it.
Result: The function returns None (since no return statement exists).
Fix: Add return grid as the last line of the function.