Which class?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
public class Ship extends SmoothMover
{
private GreenfootImage Rocket;
// private double mass;
private static final double GRAVITY = 0.5;
private int vSpeed;
public Ship ()
{
Vector intial = new Vector(Greenfoot.getRandomNumber(360), .6);
setRotation(270);
}
public void act()
{
move();
checkKeys();
//applyForces();
vSpeed += GRAVITY; // add constant acceleration due to gravity
setLocation(getX(), getY()+vSpeed); // fall (or rise)
// if collision, adjust location and zero vSpeed
}
public void checkKeys()
{
if(Greenfoot.isKeyDown("left")) {
turn(-5);
}
if(Greenfoot.isKeyDown("right")) {
turn(5);
}
ignite (Greenfoot.isKeyDown("down"));
}
private void ignite (boolean thrust)
{
if (thrust == true)
{
Vector power = new Vector(getRotation(), .2);
addToVelocity(power);
setImage("rocketWithThrust.png");
}
else
{
setImage("rocket.png");
}
}
}