tile animation: animation is now controlled by tiles.rc

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@732 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-07-17 20:11:54 +00:00
parent 8d940ec99d
commit 3859ca16d7
5 changed files with 65 additions and 113 deletions

View file

@ -0,0 +1,55 @@
package micropolisj.engine;
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
public class Tiles
{
static final Charset UTF8 = Charset.forName("UTF-8");
static TileSpec [] tiles = new TileSpec[960];
static {
try {
readTiles();
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
static void readTiles()
throws IOException
{
tiles = new TileSpec[960];
Properties tilesRc = new Properties();
tilesRc.load(
new InputStreamReader(
Tiles.class.getResourceAsStream("/tiles.rc"),
UTF8
)
);
for (int i = 0; i < tiles.length; i++) {
String tileName = Integer.toString(i);
String rawSpec = tilesRc.getProperty(tileName);
if (rawSpec == null) {
continue;
}
tiles[i] = TileSpec.parse(i, rawSpec);
}
for (int i = 0; i < tiles.length; i++) {
String tmp = tiles[i].getAttribute("becomes");
if (tmp != null) {
tiles[i].animNext = get(Integer.parseInt(tmp));
}
}
}
public static TileSpec get(int tileNumber)
{
return tiles[tileNumber];
}
}