From ba7ade2fa48662b5b471f2f8166d1a6155869b87 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Sat, 20 Jul 2013 21:34:58 +0000 Subject: [PATCH] tile-animation: let tiles.rc determine coal plant's smoke animation git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@757 d9718cc8-9f43-0410-858b-315f434eb58c --- graphics/tiles.rc | 8 ++++---- src/micropolisj/engine/MapScanner.java | 19 +++++++++---------- src/micropolisj/engine/TileSpec.java | 1 + src/micropolisj/engine/Tiles.java | 4 ++++ 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/graphics/tiles.rc b/graphics/tiles.rc index 97bbf58..42f2d54 100644 --- a/graphics/tiles.rc +++ b/graphics/tiles.rc @@ -761,12 +761,12 @@ # BEGIN COAL POWER # 745 coal@0,0 (conducts) 746 coal@16,0 (conducts) -747 coal@32,0 (conducts) (becomes=916) -748 coal@48,0 (conducts) (becomes=920) +747 coal@32,0 (conducts) (onpower=916) +748 coal@48,0 (conducts) (onpower=920) 749 coal@0,16 (conducts) 750 coal@16,16 (zone)(conducts) -751 coal@32,16 (conducts) (becomes=924) -752 coal@48,16 (conducts) (becomes=928) +751 coal@32,16 (conducts) (onpower=924) +752 coal@48,16 (conducts) (onpower=928) 753 coal@0,32 (conducts) 754 coal@16,32 (conducts) 755 coal@32,32 (conducts) diff --git a/src/micropolisj/engine/MapScanner.java b/src/micropolisj/engine/MapScanner.java index 1e15276..e695901 100644 --- a/src/micropolisj/engine/MapScanner.java +++ b/src/micropolisj/engine/MapScanner.java @@ -1334,16 +1334,15 @@ class MapScanner */ void coalSmoke() { - final int [] SmTb = { COALSMOKE1, COALSMOKE2, COALSMOKE3, COALSMOKE4 }; - final int [] dx = { 1, 2, 1, 2 }; - final int [] dy = { -1, -1, 0, 0 }; - - for (int z = 0; z < 4; z++) { - int tile = city.getTile(xpos+dx[z], ypos+dy[z]) & LOMASK; - if (tile >= COALBASE && tile < COALBASE + 4*4) { - city.setTile(xpos + dx[z], ypos + dy[z], - (char) (SmTb[z] | PWRBIT) - ); + for (int dx = -1; dx <= 2; dx++) { + for (int dy = -1; dy <= 2; dy++) { + int tile = city.getTile(xpos+dx, ypos+dy); + TileSpec ts = Tiles.get(tile & LOMASK); + if (ts != null && ts.onPower != null) { + city.setTile(xpos + dx, ypos + dy, + (char) (ts.onPower.tileNumber | (tile & ALLBITS)) + ); + } } } } diff --git a/src/micropolisj/engine/TileSpec.java b/src/micropolisj/engine/TileSpec.java index 04f071a..977e71a 100644 --- a/src/micropolisj/engine/TileSpec.java +++ b/src/micropolisj/engine/TileSpec.java @@ -6,6 +6,7 @@ public class TileSpec { int tileNumber; TileSpec animNext; + TileSpec onPower; boolean canBurn; boolean canConduct; boolean zone; diff --git a/src/micropolisj/engine/Tiles.java b/src/micropolisj/engine/Tiles.java index 1a69527..c8e949b 100644 --- a/src/micropolisj/engine/Tiles.java +++ b/src/micropolisj/engine/Tiles.java @@ -45,6 +45,10 @@ public class Tiles if (tmp != null) { tiles[i].animNext = get(Integer.parseInt(tmp)); } + tmp = tiles[i].getAttribute("onpower"); + if (tmp != null) { + tiles[i].onPower = get(Integer.parseInt(tmp)); + } } }