9 package micropolisj.engine;
11 import java.io.Serializable;
13 import static micropolisj.engine.TileConstants.RIVER;
14 import static micropolisj.engine.TileConstants.RZB;
15 import static micropolisj.engine.TileConstants.TINYEXP;
16 import static micropolisj.engine.TileConstants.TREEBASE;
17 import static micropolisj.engine.TileConstants.checkWet;
18 import static micropolisj.engine.TileConstants.isBridge;
19 import static micropolisj.engine.TileConstants.isCombustible;
20 import static micropolisj.engine.TileConstants.isZoneCenter;
29 public abstract class Sprite implements Serializable {
64 return city.
getTile(xpos, ypos);
93 city.fireSpriteMoved(
this);
100 return this.
frame != 0;
109 static int getDir(
int orgX,
int orgY,
int desX,
int desY) {
110 final int Gdtab[] = {
111 0, 3, 2, 1, 3, 4, 5, 7, 6, 5, 7, 8, 1
113 int dispX = desX - orgX;
114 int dispY = desY - orgY;
116 int z = dispX < 0 ? (dispY < 0 ? 11 : 8) : (dispY < 0 ? 2 : 5);
118 dispX = Math.abs(dispX);
119 dispY = Math.abs(dispY);
122 if(dispX * 2 < dispY)
124 else if(dispY * 2 < dispX)
127 if(z >= 1 && z <= 12) {
139 static final int getDis(
int x0,
int y0,
int x1,
int y1) {
140 return Math.abs(x0 - x1) + Math.abs(y0 - y1);
153 city.makeExplosionAt(
x,
y);
191 public void remove() {
192 this.city.
sprites.remove(
this);
200 final boolean checkSpriteCollision(
Sprite otherSprite) {
206 return (getDis(this.
x, this.
y, otherSprite.
x, otherSprite.
y) < 30);
213 final void destroyTile(
int xpos,
int ypos) {
217 int t = city.
getTile(xpos, ypos);
221 city.
setTile(xpos, ypos, RIVER);
224 if(!isCombustible(t)) {
227 if(isZoneCenter(t)) {
228 city.killZone(xpos, ypos, t);
230 city.makeExplosion(xpos, ypos);
234 city.
setTile(xpos, ypos, RIVER);
237 city.
setTile(xpos, ypos, TINYEXP);
251 static final int turnTo(
int p,
int d) {