PAT 204/504: Creative Coding (Fall 2025)
Due at 11:59pm ET on September 17
Implement a simple paddle ball game in Processing.
ballSpeed
, which defaults to 10).Please submit your code as a PDE file and the final rendering as an animated GIF file.
Now, let’s make this game more fun and challenging:
Please submit your code as a PDE file and the final rendering as an animated GIF file. Try your best to demonstrate the stickiness by moving the paddle when catching the ball.
Here is a template sketch for you to get started with:
boolean isGameOver = false; // whether the game is over
boolean saveFrames = false; // whether to save the frames
float barWidth = 60; // width of the paddle bar
float barHeight = 10; // height of the paddle bar
float ballSpeed = 10; // speed of the ball
float ballWidth = 10; // width of the ball
// DEFINE OTHER GLOBAL VARIABLES YOU NEED HERE
// Initialize the game
void init() {
// YOUR CODE HERE
}
void setup() {
// Create a 400x400 canvas
size(400, 400);
// Set the frame rate to 30 fps
frameRate(30);
// YOUR CODE HERE
// Initialize the game
init();
}
void draw() {
// Check if the game is over
if (isGameOver) {
// Save the frame for making an animated GIF
if (saveFrames) {
saveFrame("frames/###.png");
}
// Return immediately if the game is over
return;
}
// YOUR CODE HERE
// Save the frame for making an animated GIF
if (saveFrames) {
saveFrame("frames/###.png");
}
}
// Reset the game when the mouse is clicked
void mouseClicked() {
init();
}
Note that the template includes a boolean switch saveFrames
that controls if the saveFrame()
function at the end of the draw()
function will be executed. When saveFrames
is set to true, each frame generated by a call of the draw()
function will be saved to the folder frames/
in the project directory. You can then use the built-in movie maker (“Tools > Movie Maker”) to create an animated GIF. Also, the GIF standard does not support 60 fps, so we need to add frameRate(30)
to the setup()
function to set the frame rate to 30 fps.
bin/
folder) to “C:\Users\[USERNAME]\Documents\Processing\tools\MovieMaker\tool”pmouseX
and mouseX
, where pmouseX
stores the value of mouseX
in the previous frame.