I am making a simple game for my computer class and i've learned the basic commands including the counting method where you put "int count = 0" and "count = count + 1" and "if (count == 5)" and all that but what i want to know is how to make an actor rise up and make it come down after a while.
my codes for my jump method is
if (Greenfoot.isKeyDown("space"))
{
setLocation(getX(), getY() - 8);
if (Greenfoot.isKeyDown("right"))
{
move(+2);
}
if (Greenfoot.isKeyDown("left"))
{
move(-2);
}
if (count == 4)
{
setLocation(getX(), getY() + 8);
}
}
------------------------------------------------------------------------------------------------------------ i know this is doing what it supposed to but i want the actor to stay up in the air for a visible while and come back down, and i can only use the codes i have learned.
these two parts (the code below) are there because i want the actor to jump towards the direction i am moving
if (Greenfoot.isKeyDown("right"))
{
move(+2);
}
if (Greenfoot.isKeyDown("left"))
{
move(-2);
}
thanks in advance :)