import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Base class for projectiles and other kinds of things one can shoot on his enemies. * * @author Martin Schend, Jannis Andrija Schnitzer * @version 2011-01-21 */ public class Missile extends QuantumObject { protected int side; protected int damage; // TODO: damage multipliers or somesuch? public void act() { super.act(); } public void setSide(int gun_side) { side = gun_side; } public int getSide() { return side; } public void setDamage(int the_damage) { damage = the_damage; } public int getDamage() { return damage; } /** * Dummy hit function that allows for dummy missiles. Upon hitting a spaceship from the other side, * the missile is destroyed. * * The missile itself doesn't subtract hit points from the spaceship, it's Spaceship.hit(Missile) doing that. * This way of coding doesn't allow for flawfully programmed Spaceship subclasses, but it's more flexible. * * @see Spaceship#hit(Missile) */ public boolean hit(Spaceship s) { if (s.getSide() == side) // the spaceship is ours return true; else return false; // they (should) have hitpoints subtracted! } }