Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Creating Simple Game in Processing with

Actor Class
• Goal: Create simple interactive 2D
game.
• Give you ideas for your own final
project.
• Collision Detection
• Scoring
• Printing Text on Screen
• Mouse Control
Create Blank Processing Project:
• Save: “SimpleGame”
• Setup Main Tab:
-void setup()
-Canvas size of 600, 400
-void draw()
-Choose background color
Note Class names for Game:
• class Bouncer extends Actor
• Instance name ball
• class Opponent extends Actor
• Instance name opponent
• class Player extends Actor Bouncer Opponent
ball opponent
• Instance name player Player
player
Add Actor Class
• Create Actor Tab
• Copy and Paste Actor
Class from your
lastname_actor project
• Or: get code from:
http://nebomusic.net/processinglessons
/Actor.txt
Add Bouncer Class
• Create Tab Bouncer
• Write Code
• (Don’t Run yet – you will
get errors)
Add Opponent Class
• Create Tab Opponent
• Write Code
Add Player Class
• Create Tab Player
• Write Code:
Modify SimpleGame Tab
• Add instances of:
• ball
• player
• Opponent
• Call the .act() functions of
instances in void draw()
• Write the code to display the
score
What else can you add?
• Drawing functions for different objects in Bouncer, Player, and
Opponent.
• Background decoration.
• Way to decrease Score if ball touches left wall
• Hint: if (ball.x < 2)
• Multiple Bounces instances
• Randomness
• Change direction of Game (Up and Down versus Right to Left)

You might also like