hello,
how to calculate how many X you moved and how many Y you moved? i need to know the changeX and changeY for putting it as parameters into a function:
that was my move and next is the function i need it for:
the code to shiftscreen is in the worldclaas while the code for move is in an actor.
private void move()
{
if(Greenfoot.isKeyDown("up")){
move(3);
}
if(Greenfoot.isKeyDown("down")){
move(-3);
}
if(Greenfoot.isKeyDown("right")){
turn(4);
}
if(Greenfoot.isKeyDown("left")){
turn(-4);
}
}public void shiftScreen(int changeX, int changeY)
{
leftBound += changeX;
rightBound += changeX;
if(leftBound < 0){
leftBound = 0;
rightBound = getWidth();
}
else if(rightBound > MAPWIDTH){
rightBound = MAPWIDTH;
leftBound = MAPWIDTH - getWidth();
}
topBound -= changeY;
bottomBound -=changeY;
if (topBound < 0){
topBound = 0;
bottomBound = getHeight();
}
else if(bottomBound > MAPHEIGHT){
bottomBound = MAPHEIGHT;
topBound = MAPHEIGHT - getHeight();
}
update();
}
