1 package se
.umu
.cs
.dit06ajnajs
.map
;
3 import java
.awt
.Graphics
;
6 import java
.util
.Observable
;
8 import se
.umu
.cs
.dit06ajnajs
.Paintable
;
9 import se
.umu
.cs
.dit06ajnajs
.AntiTD
;
11 public abstract class MapSquare
extends Observable
implements Paintable
,
21 public MapSquare(int x
, int y
, Image image
) {
27 public void paint(Graphics g
) {
28 g
.drawImage(image
, x
, y
, null);
31 public Point
getPosition() {
32 Point p
= new Point(x
, y
);
36 public Point
getCenterPoint() {
37 return new Point(this.centerX
, this.centerY
);
40 public int getCenterX() {
44 public int getCenterY() {
52 public void setX(int x
) {
54 this.centerX
= this.x
+ (AntiTD
.SQUARE_SIZE
/2);
61 public void setY(int y
) {
63 this.centerY
= this.y
+ (AntiTD
.SQUARE_SIZE
/2);
66 public void setImage(Image img
) {
71 * Empty method, ovveridden by subclass to implement behaviour.
77 * Attemts to clone this MapSquare.
79 * @return A new instance of the same type as the instantiated MapSquare.
82 public Object
clone() {
85 } catch (CloneNotSupportedException e
) {
87 throw new Error("Object " + this.getClass().getName()
88 + " is not Cloneable");
93 public String
toString() {
94 return "MapSquare: " + this.getClass().getName()
95 + " @("+ x
+", " + y
+")";