Hi!
I have been creating a game in which you have a motionX and a motionY and when you hold down left, X will go down meaning the person will keep moving left. What I can't understand is how my program doesn't appear to subtract the motionX value. Here is my code:
import greenfoot.*;
/**
* Write a description of class Person here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Person extends Actor
{
int MotionX = 0;
int MotionY = 0;
/**
* Act - do whatever the Person wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setLocation( getX() + MotionX , getY() ) ;
if (Greenfoot.isKeyDown("left"))
{
int sum = MotionX -1;
}
}
}
