I have a problem, I am making a game when you press the space bar the owl wearing a suit jumps (agent X for short) but if you hold down the spacebar agent x flys, I don't want him to fly because then the game would be to easy and I would rather have it be to hard then to easy, because easy=boring hard=fun+addicting. Here is my code:
Can someone please help?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class player here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class player extends Actor
{
public int vspeed = 0;
public int ac = 1;
/**
* Act - do whatever the player wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
motion();
fall();
onGround();
checkfall();
}
private void motion()
{
if (Greenfoot.isKeyDown("right")) {
move(3);
}
if (Greenfoot.isKeyDown("left")) {
move(-3);
}
if (Greenfoot.isKeyDown("space"))
{
jump();
}
}
public void fall()
{
setLocation (getX(), getY() + vspeed);
vspeed = vspeed + ac;
}
public boolean onGround()
{
Actor under = getOneObjectAtOffset ( 0, 19, grass.class);
return under != null;
}
public void checkfall()
{
if(onGround())
{
vspeed = 0;
}
}
public void jump()
{
vspeed = -4;
}
}

