I wanted to make my ball bounce off the walls, bricks, and the paddle, but I have no idea how to do it.I have only used Greenfoot for 3 days and I don't know how.
this is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class ball here. * * @author (your name) * @version (a version number or a date) */ public class ball extends Actor { /** * Act - do whatever the ball wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ private int delaytime = 150 ; public void act() { turn(- 45 ); move( 1 ); turn( 45 ); } } |