tile animation: make industrial zone smoke animations initiated by tiles.rc

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@760 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-07-20 21:35:09 +00:00
parent 0c497aa434
commit 7540682a06
3 changed files with 49 additions and 150 deletions

View file

@ -1,42 +0,0 @@
// This file is part of MicropolisJ.
// Copyright (C) 2013 Jason Long
// Portions Copyright (C) 1989-2007 Electronic Arts Inc.
//
// MicropolisJ is free software; you can redistribute it and/or modify
// it under the terms of the GNU GPLv3, with additional terms.
// See the README file, included in this distribution, for details.
package micropolisj.engine;
import static micropolisj.engine.TileConstants.*;
/**
* Contains data used for tile animation.
*/
class Animate
{
/**
* Contains data used for industrial zone animations.
*/
static class Smoke
{
// There are eight full Industry-zone images in the tiles bank.
// This array indicates which of those eight zones have an animation.
static boolean [] AniThis = {true, false, true, true, false, false, true, true };
// Up to two tiles can be animated. Arrays DX1,DY1 indicate the relative
// position of the first animated tile.
static int [] DX1 = { -1, 0, 1, 0, 0, 0, 0, 1 };
static int [] DY1 = { -1, 0, -1, -1, 0, 0, -1, -1 };
// Arrays DX2,DY2 indicate the second animated tile.
static int [] DX2 = { -1, 0, 1, 1, 0, 0, 1, 1 };
static int [] DY2 = { -1, 0, 0, -1, 0, 0, -1, 0 };
static int [] AniTabA = { 0, 0, 32, 40, 0, 0, 48, 56 };
static int [] AniTabB = { 0, 0, 36, 44, 0, 0, 52, 60 };
static int [] AniTabC = { IND1, 0, IND2, IND4, 0, 0, IND6, IND8 };
static int [] AniTabD = { IND1, 0, IND3, IND5, 0, 0, IND7, IND9 };
}
}

View file

@ -12,7 +12,6 @@ import java.util.*;
import static micropolisj.engine.TileConstants.*;
import static micropolisj.engine.Micropolis.ZoneType;
import static micropolisj.engine.Animate.Smoke;
/**
* Process individual tiles of the map for each cycle.
@ -822,63 +821,6 @@ class MapScanner
}
}
/**
* Animate tiles in an industrial zone.
* Note: pollution is not accumulated here; it is instead
* accumulated in ptlScan(), by adding up each tile's
* pollution value.
*
* @param powerOn indicates whether the building has power
*/
void setSmoke(boolean powerOn)
{
int cchr9 = cchr & LOMASK;
if (cchr9 < IZB)
return;
int z = ((cchr9 - IZB) / 8) % 8;
if (Smoke.AniThis[z])
{
int xx = xpos + Smoke.DX1[z];
int yy = ypos + Smoke.DY1[z];
if (city.testBounds(xx, yy))
{
int t = city.map[yy][xx] & LOMASK;
if (powerOn) {
if (t == Smoke.AniTabC[z]) //expected non-animated tile
{
city.setTile(xx,yy,(char)(SMOKEBASE + Smoke.AniTabA[z]));
}
}
else {
if (t > Smoke.AniTabC[z]) {
city.setTile(xx,yy,(char)(Smoke.AniTabC[z]));
}
}
}
xx = xpos + Smoke.DX2[z];
yy = ypos + Smoke.DY2[z];
if (city.testBounds(xx, yy) && !(Smoke.DX1[z] == Smoke.DX2[z] && Smoke.DY1[z] == Smoke.DY2[z]))
{
int t = city.map[yy][xx] & LOMASK;
if (powerOn) {
if (t == Smoke.AniTabD[z]) {
city.setTile(xx,yy,(char)(SMOKEBASE + Smoke.AniTabB[z]));
}
}
else {
if (t > Smoke.AniTabD[z]) {
city.setTile(xx,yy,(char)(Smoke.AniTabD[z]));
}
}
}
}
}
/**
* Called when the current tile is the key tile of an
* industrial zone.
@ -887,7 +829,6 @@ class MapScanner
void doIndustrial(boolean powerOn)
{
city.indZoneCount++;
setSmoke(powerOn);
int tpop = industrialZonePop(cchr);
city.indPop += tpop;