i dont want the game to register 2 buttons at a time so in other words i dont want the players to go in a diagonal line only left right and up and down.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Red here. * * @author (your name) * @version (a version number or a date) */ public class Red extends Players { /** * Act - do whatever the Red wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(); //trail(); //delay(); //win(); } public void move() { if(Greenfoot.isKeyDown("up")) { setLocation(getX(), getY()-4); } if (Greenfoot.isKeyDown("down")) { setLocation(getX(), getY()+4); } if (Greenfoot.isKeyDown("right")) { setLocation(getX()+4, getY()); } if (Greenfoot.isKeyDown("left")) { setLocation(getX()-4, getY()); } } public void trail() { } public void win() { } }