Concept: Learning Through Play with Panda Math Stack
For my midterm project, I chose to integrate a simple math operation game into my p5 sketch. The Panda Math Stack transforms simple arithmetic into an interactive adventure where learning meets play. Designed with cheerful visuals and smooth animation, the game combines the task of a running panda collecting pancakes to make math practice fun and rewarding. Players solve addition problems by catching and stacking pancakes that match the correct answer. With every correct answer, the panda celebrates as cheerful sound effects and background music enhance the sense of accomplishment.
The game’s 30-second timer adds excitement, encouraging quick thinking while keeping learners engaged. Beyond its playful surface, Panda Math Stack promotes cognitive growth, especially for kids, through repetition and visual reinforcement, showing that learning can be both joyful and challenging in the right balance of design, music, and motion.
Explanation of The Main Components:
1. Use of Sounds
Sound plays an important emotional and feedback role in Panda Math Stack. The game includes three primary sound effects: background music (bgMusic
), a stacking sound (boinkSound
), and a game-over sound (gameOverSound
). The looping background track establishes an upbeat rhythm that keeps players engaged throughout gameplay. The short “boink” effect provides instant positive feedback every time a pancake successfully lands on the tray, reinforcing the satisfaction of correct stacking. Finally, the game-over sound signals the end of a round, helping players transition between play sessions. Together, these sounds create a responsive and immersive auditory experience that strengthens player focus and motivation.
2. Use of Shapes
Shapes in this project are used to render most visual elements directly in p5.js without relying on external images. Circles and ellipses form pancakes, clouds, and decorative symbols, while rectangles and triangles are used for UI buttons and the grassy ground. By layering and coloring these basic shapes, the design achieves a friendly, cartoon-like appearance. The pancakes themselves use multiple overlapping ellipses in different brown tones, giving them dimension and warmth. This approach demonstrates how simple geometric forms can produce visually appealing and cohesive game elements that maintain a light, playful aesthetic.
3. Use of Images for Sprite Sheet
The panda character’s animation is handled using a sprite sheet (panda.png
or panda2.png
), divided into multiple frames organized in rows and columns. Each frame represents a different pose of the panda walking or idle. During gameplay, the code cycles through these frames (currentFrame
) to simulate movement. This sprite-based animation technique allows smooth transitions without heavy computation, making the character appear lively and expressive as it moves and interacts with falling pancakes. The use of images here contrasts with the drawn shapes, introducing a visually rich and character-focused element that enhances personality and storytelling in the game.
4. On-Screen Text Evolution
Text evolves dynamically to communicate progress and emotions to the player. At the start, large pixel-style fonts announce the title and instructions, creating a retro arcade feel. During gameplay, text displays math problems, timers, and feedback messages that change in color and size depending on correctness (✅
for success, ❌
for errors). In the end screen and notebook view, typography shifts toward clarity and encouragement, summarizing scores or reviewing mistakes. This continuous adaptation of on-screen text keeps information readable while reinforcing the game’s educational purpose — transforming numbers and feedback into part of the visual storytelling.
5. Object-Oriented Programming in notebook.js
and pancake.js
Both notebook.js
and pancake.js
apply object-oriented programming (OOP) principles to organize behavior and state efficiently. The Pancake
class defines how each pancake behaves — from falling physics (update
) to visual rendering (show
) — encapsulating movement, collisions, and display logic into self-contained objects. Similarly, the Notebook
class manages data storage and visualization of wrong answers, using methods like addWrong()
, display()
, and drawStack()
to handle user progress and draw interactive visual feedback. This modular, class-based approach makes the code easier to scale, reuse, and maintain, as each object represents a distinct component of the game world with its own properties and responsibilities.
Code I am Proud of:
function checkAnswer() { if (!roundActive) return; if (stack.length === targetStack) { // Correct number of pancakes correctRounds++; message = `✅ Correct! (${num1} + ${num2} = ${targetStack})`; messageTimer = millis(); roundActive = false; setTimeout(() => newMathProblem(), 1500); if (boinkSound) boinkSound.play(); } else { // Incorrect answer message = "❌ Try Again!"; messageTimer = millis(); let question = `${num1} + ${num2}`; notebook.addWrong?.(question, targetStack, num1, num2); stack = []; pancakes = []; } }
The checkAnswer()
function is the core of the game’s math logic — it checks whether the number of pancakes the player stacked matches the correct answer to the math problem shown on screen. When the player presses “Check,” the function compares the length of the stack
array (how many pancakes were caught) to targetStack
(the sum of num1 + num2
). If they’re equal, the player’s answer is correct — their score (correctRounds
) increases, a success message and sound play, and a new math problem appears after a short delay. If the count is wrong, an error message is displayed, the pancakes reset, and the player can try again, making this function the key link between the math challenge and interactive gameplay.
Through Beta Testing:
Through beta testing, I received valuable feedback from my friends, that helped shape the final version of Panda Math Stack. They suggested transforming the concept into a math-based problem-solving game rather than just a stacking challenge, as this would make it more educational and purposeful.
They also recommended developing the notebook feature to track incorrect answers, allowing players to review and learn from their mistakes after each round. Incorporating these suggestions not only improved the gameplay experience but also strengthened the project’s learning component, making it both fun and pedagogically meaningful.