need help with dodgeball game. i need it so the character can pick up the ball, and throw it to its left whenever a button is pressed.
import greenfoot.*;
/**
* Write a description of class Char1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Char1 extends Mover
{
private int balls;
private int direction;
public Char1()
{
balls = 0;
}
public void act()
{
movement();
checkCollision();
}
public void movement()
{
if (Greenfoot.isKeyDown("left"))
{
move(-2);
}
if (Greenfoot.isKeyDown("right"))
{
move(2);
}
if (Greenfoot.isKeyDown("up"))
{
setLocation(getX(), getY()-2);
}
if (Greenfoot.isKeyDown("down"))
{
setLocation(getX(), getY()+2);
}
}
}