import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class ManuallyControlledSpaceship here. * * @author (your name) * @version (a version number or a date) */ public class ManuallyControlledSpaceship extends Spaceship { /** * Act - do whatever the ManuallyControlledSpaceship wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public ManuallyControlledSpaceship() { super(); this.setRotation(-90); BulletBillGun bg = new BulletBillGun(-30.0, 0.0); bg.set_dy(42); // set distance to spaceship this.addGun(0, bg); } public void act() { super.act(); if (Greenfoot.isKeyDown("left")) { setLocation(getX()-10, getY()); } if (Greenfoot.isKeyDown("right")) { this.setLocation(getX()+10, getY()); } if (Greenfoot.isKeyDown("space")) { fire(); } } }