

This shows the documentation (API) for the Actor class in Greenfoot How does an actor check if it is hitting (intersection with another actor)? How do you get the current location of the actor (x and y values)? How do you set the current location? How do you change the image of the actor? All subclasses of Actor such as Paddle and Ball can do all of these as well. Public class Paddle extends Actor A paddle object has the following fields: width – of the paddle height – of the paddle moveAmount – amount to move the paddle color – of the paddle BreakoutĦ What can actors do? Double click on the Actor class Breakoutĥ The Paddle Class Paddle is a subclass of Actor

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 in Breakout-export to show them the final game working. BreakoutĤ Game Rules Use the left and right arrow keys to move the paddle 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. Presentation on theme: "Breakout in Greenfoot Barb Ericson"- Presentation transcript:ġ Breakout in Greenfoot Barb Ericson Institute of Technology September 2010 BreakoutĢ What are the objects? Open Breakout.html in Breakout-exportĪnd play the game (use the arrow keys to move the paddle and hit the ball into the bricks) How do you lose? How do you win? What are the objects in the game? Breakout prevent ball from going through walls by changing its velocity

prevent paddles from going through wallsĬontext. check for collision between two objects using axis-aligned bounding box (AABB)Ĭontext. ball velocity (start going to the top-right corner) keep track of when need to reset the ball position Greenfoot Lesson 13 - Make a Score Counter - YouTube 0:00 / 16:29 Greenfoot Lesson 13 - Make a Score Counter Jim Stewart 1.01K subscribers Subscribe 334 67K views 9 years ago Greenfoot. start in the middle of the game on the right side start in the middle of the game on the left side getContext ( '2d' ) Ĭonst maxPaddleY = canvas. getElementById ( 'game' ) Ĭonst context = canvas. When you become a Patron, you get access to behind the scenes development logs, the ability to vote on which games I work on next, and early access to the next Basic HTML Game. Other Basic Gamesīasic HTML Games are made possible by users like you. Giving attribution is not required, but appreciated.

There's no need to ask permission before using these.
#Greenfoot ping pong code
(CC0 1.0 Universal) You're free to use this game and code in any project, personal or commercial.
#Greenfoot ping pong series
This series is meant to give a basic outline of the game but nothing more. Important note: I will answer questions about the code but will not add more features or answer questions about adding more features. For example, if it hit the topmost part of the paddle it should have a sharp angle upward, whereas if it hit the direct middle of the paddle it should move completely flat towards the other payer.
