package org.easy.gui.ani.sprite;
import org.easy.gui.Component;
import org.easy.gui.Graphics;
import org.easy.gui.Painter;
import org.easy.gui.Rectangle;
import org.easy.gui.Updater;
import org.easy.gui.ani.Sprite;
import org.easy.gui.ani.painter.NullPainter;
import org.easy.gui.ani.updater.NullUpdater;
public abstract class AbstractSprite implements Sprite {
protected double x;
protected double y;
protected double z;
protected double heading;
protected double velocity;
protected Updater updater;
protected Painter painter;
public AbstractSprite(double x, double y, double z, double heading, double velocity,
Updater updater,
Painter painter) {
this.x = x;
this.y = y;
this.z = z;
this.heading = heading;
this.velocity = velocity;
setUpdater(updater);
setPainter(painter);
}
public AbstractSprite() {
this(0.0, 0.0, 0.0, 0.0, 0.0, null, null);
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public double getHeading() {
return heading;
}
public double getVelocity() {
return velocity;
}
public void getCollisionBounds(Rectangle<Integer> collisionBounds) {
collisionBounds.setBounds(getCollisionShape().getBounds());
}
//////////////////////////////////////////////////////////////////////
// mutator methods
//////////////////////////////////////////////////////////////////////
public void setX(double x) {
this.x = x;
}
public void setY(double y) {
this.y = y;
}
public void setZ(double z) {
this.z = z;
}
public void setHeading(double heading) {
this.heading = heading;
}
public void setVelocity(double velocity) {
this.velocity = velocity;
}
public void setUpdater(Updater updater) {
if (updater == null) {
updater = NullUpdater.INSTANCE;
}
this.updater = updater;
}
public void setPainter(Painter painter) {
if (painter == null) {
painter = NullPainter.INSTANCE;
}
this.painter = painter;
}
public void update(Component component) {
updater.update(component);
}
public void paint(Component component, Graphics graphics) {
painter.paint(component, graphics);
}
}
|