Breakout in Greenfoot Barb Ericson

Slides:



Advertisements
Similar presentations
Create a Simple Game in Scratch
Advertisements

SimpleGameInAlice1 Barb Ericson Georgia Institute of Technology June 2008 Creating a Simple Game in Alice.
Mike Scott University of Texas at Austin
Create a Simple Game in Scratch
Scratch is a Visual Programming Language
The Point Class public class Point { public double x; public double y; public Point(double x0, double y0) { x = x0; y = y0; } public double distance(Point.
Chapter 10 - Additional Scenario Ideas Bruce Chittenden.
Microsoft® Small Basic Advanced Games Estimated time to complete this lesson: 1 hour.
Harry Potter Scratch Game
Adventures in Animation Harry Potter Game Pranali Choubal Kunal Shaw Barb Ericson Dec 2007.
Games and Simulations O-O Programming in Java The Walker School
Animation Mrs. C. Furman. Animation  We can animate our crab by switching the image between two pictures.  crab.png and crab2.png.
Program: Little Crab Mr Gano.
A Christmas Scratch game
Pulling out a common superclass Barb Ericson Georgia Tech.
Extending the Pong Example Barb Ericson Georgia Tech June 2011.
Games and Simulations O-O Programming in Java The Walker School
GAME:IT Junior Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
GameMaker.  A lot of Different Definitions  Easier to Say What is NOT a Game  Movie is Not a Game  No Active Participation  Final Outcome is Fixed.
Creating pong in scratch Learning objectives: To learn how to program Sensing via colour and sprite proximity O:\ICT\ks3\scratch\scratch Exercises\Creating.
Game Design Creating a game called PING Phase 3: Steps for building basic game.
Game Maker Day 2 Making a Maze Game.
Locally Edited Animations We will need 3 files to help get us started at
Problem Solving with Data Structures using Java: A Multimedia Approach Chapter 14: Using an Existing Simulation Package.
Twenty Questions … all about tennis! Twenty Questions
Miss Acevedo Individual Sports Unit 2- Semester 1
VIDEO GAME PROGRAMMING Video Game Programming Level One – Breakout INSTRUCTOR Big Dan Teague TEACHER’S ASSISTANT Delmar O'Donnell.
KeyListener and Keyboard Events Just as we can implement listeners to handle mouse events, we can do the same for keyboard events (keypresses) –to implement.
©Robomatter – Distribution or copying without permission is prohibited. 3B STEM Computer Science 1 ©Robomatter – Distribution or copying without permission.
Art 315 Lecture 5 Dr. J. Parker AB 606. Last time … We wrote our first program. We used a tool called GameMaker. The program we wrote causes a ball to.
Alice Pong Recreating Pong in Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June 2010.
Programming Video Games
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
Design Studies 20 ‘Show Off’ Project How to make a computer monitor In Google Sketchup By: Liam Jack.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
EGR 115 Introduction to Computing for Engineers 3D animation in MATLAB Monday 17 Nov 2014 EGR 115 Introduction to Computing for Engineers.
Georgia Institute of Technology Creating Classes part 4 Barb Ericson Georgia Institute of Technology May 2006.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
Today we are learning to: Understand how actions and events control our game. Completing the catch the clown game – making a room – adding music Gather.
Today we are learning to: Understand how flow charts are used to design games Add events to our objects to control stuff in our game – (Using the user.
Integer Football Welcome to Integer Football!
Frog Rock Youth Basketball Division I Playing Rules Primary objectives: Provide players opportunity to develop fundamental basketball skills Provide players.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
Chapter 2 – The Little Crab Program:. Little Crab Scenario Inheritance: The Arrows Denote Hierarchy Crab is an Animal Animal is an Actor Therefore, It.
Creating Scenarios In Greenfoot. Greenfoot Scenarios are made up of: Greenfoot Scenarios are made up of: A World class. A World class. Actor classes.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
GAME:IT Junior Paddle Ball Objectives: Review skills from Introduction Create a background Add simple object control (up and down) Add how to create a.
GAME:IT Paddle Ball Objectives: Review skills from Introduction Create a background Add simple object control (up and down) Add how to create a simple.
Newton’s Lab Games and Simulations O-O Programming in Java.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Sound and more Animations
Create a Halloween Computer Game in Scratch
Breakout 3D Jeremy Quick.
Animation & Games Module
Barb Ericson Georgia Institute of Technology June 2007
Version 2.
Two-Dimensional Arrays and Nested Loops – part 1
The One Where You Scratch
Two-Dimensional Arrays and Nested Loops – part 1
Go to =>
Problem Solving with Data Structures using Java: A Multimedia Approach
Games and Simulations O-O Programming in Java The Walker School
Breakout in Greenfoot Barb Ericson
Creating a Simple Game in Scratch
So you want to be a Game Designer
This Photo by Unknown Author is licensed under CC BY-NC-ND
Presentation transcript:

Breakout in Greenfoot Barb Ericson ericson@cc.gatech.edu Georgia Institute of Technology Feb 2010 Breakout

The Breakout Game Open Breakout-Start There are Bricks, a Message that says we are starting with Ball 1, a Ball, and a Paddle But if you click on act or run nothing happens Give your students the Breakout-Start and Breakout-export folders. The complete game is in Breakout. Breakout

Game Rules Use the left and right arrow keys to move the paddle Use the paddle to hit the ball into the bricks to get rid of them Get rid of all the bricks to win the game The ball will bounce off most of the walls, paddle, and bricks You get up to three balls to use If you still have bricks after using 3 balls you lose If a ball hits the bottom wall it is removed and a new ball is added Use the exported applet of Breakout to show them the final game working. Breakout

Moving the Paddle (act method) Check if the left key is down if (Greenfoot.isKeyDown("left")) if it is move the paddle left setLocation(getX()-moveAmount, getY()); Check if the right key is down if (Greenfoot.isKeyDown("right")) if it is move the paddle right setLocation(getX()+moveAmount, getY()); moveAmount is a field in Paddle. Breakout

The Ball's Act Method Move the ball Check if hit any actors Set the location using the current x and y and velX and velY (amount to move in X and Y) Check if hit any actors If hit an actor and that actor isn't the message Bounce off the object Check if the object was a brick if it was a brick remove the brick from the world and have the world check if the player won (no more bricks) Check if at any walls Bounce off top or side walls If at bottom wall remove ball and create a new one Breakout

Move the Ball The ball's y velocity is 3, but it is a field velY The ball's x velocity should be a random value between 1 and 3 or -1 to -3 set in the constructor velX To move the ball setLocation(getX() + velX, getY() + velY); Breakout

Checking if hit any Actors Get an actor (an object of the class Actor) that intersects with this one Actor actor = this.getOneIntersectingObject(Actor.class); If the ball did hit an actor and the actor isn't the message (object of the Message class) if (actor != null && !(actor instanceof Message)) { Breakout

Bounce the Ball off an Actor The actor must be a paddle or a brick (if it isn't a message) So negate velY to make it switch direction in Y velY = -velY; Breakout

If the Ball hit a Brick Check using If the ball did hit a brick if (actor instanceof Brick) { If the ball did hit a brick remove the brick from the world world.removeObject(actor); check if won (last brick was removed) world.checkIfWon(); } Breakout

Checking Walls If the ball hit the left wall bounce in x if (getX() - radius <= 0) velX = -velX; // negate velocity in X if the ball hit the right wall bounce in x if (getX() + radius >= BreakoutWorld.WIDTH) if the ball hit the top wall bounce in y else if (getY() - radius <= 0) velY = -velY; // negate velocity in Y Breakout

Checking Bottom Wall remove the current ball from the world if (getY() + radius >= BreakoutWorld.HEIGHT) { remove the current ball from the world world.removeObject(this); add a new ball to the world world.newBall(); this also checks for the end of the game } Breakout

Additional Ideas Add sounds bounce sound and win or lose sounds If the ball hits at the edge of paddle then bounce in x as well as y if the distance from the center of the ball to the left or right edge of the paddle is less than or equal the radius of the ball Speed up the velocity after each 7th hit with the paddle double the x velocity Make the paddle smaller over time Change the ball color to match the last hit brick's color Add a getColor() method to Brick See the documentation for the Greenfoot classes http://www.greenfoot.org/doc/javadoc/ Breakout

Ideas for Breakout Introduce object-oriented analysis using Breakout-export Have them name the classes shown and describe the methods needed Give students Breakout-Start Have them create the full code for Breakout Breakout