9 package micropolisj.engine;
13 import micropolisj.util.Utilities;
14 import static micropolisj.engine.TileConstants.*;
25 public static class SoundInfo {
30 SoundInfo(
int x,
int y,
Sound sound) {
38 this.
tiles =
new short[0][0];
39 this.
sounds =
new ArrayList<SoundInfo>();
59 return tiles.length != 0 ?
tiles[0].length : 0;
66 boolean inRange(
int dx,
int dy) {
67 return offsetY + dy >= 0 &&
offsetY + dy < getHeight() && offsetX + dx >= 0 &&
offsetX + dx < getWidth();
70 void expandTo(
int dx,
int dy) {
72 tiles =
new short[1][1];
80 for(
int i = 0; i <
tiles.length; i++) {
84 short[] AA =
new short[newLen];
85 System.arraycopy(A, 0, AA, 0, A.length);
86 Arrays.fill(AA, A.length, newLen, CLEAR);
91 int newLen = A.length + addl;
92 short[] AA =
new short[newLen];
93 System.arraycopy(A, 0, AA, addl, A.length);
94 Arrays.fill(AA, 0, addl, CLEAR);
104 int width =
tiles[0].length;
107 short[][] newTiles =
new short[newLen][width];
108 System.arraycopy(
tiles, 0, newTiles, 0,
tiles.length);
109 for(
int i =
tiles.length; i < newLen; i++) {
110 Arrays.fill(newTiles[i], CLEAR);
116 int newLen =
tiles.length + addl;
117 short[][] newTiles =
new short[newLen][width];
118 System.arraycopy(
tiles, 0, newTiles, addl,
tiles.length);
119 for(
int i = 0; i < addl; i++) {
120 Arrays.fill(newTiles[i], CLEAR);
130 sounds.add(
new SoundInfo(dx, dy, sound));
135 public void setTile(
int dx,
int dy,
int tileValue) {