import greenfoot.*; /** * This is the human, the last survivor on earth * * @author Eric Faltermeier * @version 12/6/2017 */ public class Human extends Actor { private boolean isDown; private GreenfootImage rightImage; public Human() // This makes the human more to scale with the rest of the world. { //myImage = new GreenfootImage("Human.gif"); GreenfootImage myImage = getImage(); int myNewWidth = (int)myImage.getWidth()/8; int myNewHeight = (int)myImage.getHeight()/8; myImage.scale(myNewWidth,myNewHeight); rightImage = myImage; } public void act() { move(); } public void move() // This is where the character is controlled it makes it so the character face the right way { if (Greenfoot.isKeyDown("s")) { setLocation(getX(), getY() +2); } if (Greenfoot.isKeyDown("w")) { setLocation(getX(), getY() -2); } if (Greenfoot.isKeyDown("a")) { move(-2); if(Greenfoot.isKeyDown("a") && !isDown) { getImage().mirrorHorizontally(); isDown = true; } if(!Greenfoot.isKeyDown("a") && isDown) { isDown = false; } } if (Greenfoot.isKeyDown("d")) { setImage("Human2.gif"); GreenfootImage myImage = getImage(); int myNewWidth = (int)myImage.getWidth()/8; int myNewHeight = (int)myImage.getHeight()/8; myImage.scale(myNewWidth,myNewHeight); move(2); } } }