import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot und MouseInfo)

public class Rakete extends Actor
{
    public void act() 
    {
        this.tastaturSteuerung();
        this.checkCollision();
    }  
    public void checkCollision() {
        if(this.isTouching(Meteor.class)) {
            Explosion e = new Explosion();
            this.getWorld().addObject(e, this.getX(), this.getY());
            this.getWorld().removeObject(this);
        }
    }
    public void tastaturSteuerung() {
        if(Greenfoot.isKeyDown("w")) {
            this.moveUp();
        }
        if(Greenfoot.isKeyDown("s")) {
            this.moveDown();
        }
        if(Greenfoot.isKeyDown("a")) {
            this.moveLeft();
        }
        if(Greenfoot.isKeyDown("d")) {
            this.moveRight();
        }
        if(Greenfoot.isKeyDown("space")) {
            this.shoot();
        }
    }
    public void shoot() {
        Bullet b = new Bullet();
        this.getWorld().addObject(b, this.getX() + 90, this.getY() + 10);
    }

    public void moveUp() {
        this.setLocation(this.getX(), this.getY() - 3); 
    }

    public void moveDown() {
        this.setLocation(this.getX(), this.getY() + 3);
    }

    public void moveRight() {
        this.setLocation(this.getX() + 3, this.getY());
    }

    public void moveLeft() {
        this.setLocation(this.getX() - 3, this.getY());
    }
}