This edition of Micropolis, written for the Java desktop platform, is fairly feature complete. I believe the only missing functionality is that of loading the built-in scenarios, and this can be implemented if there is any demand for it. I will soon update the home page at http://code.google.com/p/micropolis/ with downloadable packages of this edition of the software. git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@528 d9718cc8-9f43-0410-858b-315f434eb58c
82 lines
1.5 KiB
Java
82 lines
1.5 KiB
Java
// 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;
|
|
|
|
public class TornadoSprite extends Sprite
|
|
{
|
|
static int [] CDx = { 2, 3, 2, 0, -2, -3 };
|
|
static int [] CDy = { -2, 0, 2, 3, 2, 0 };
|
|
|
|
boolean flag;
|
|
int count;
|
|
|
|
public TornadoSprite(Micropolis engine, int xpos, int ypos)
|
|
{
|
|
super(engine, SpriteKind.TOR);
|
|
this.x = xpos * 16 + 8;
|
|
this.y = ypos * 16 + 8;
|
|
this.width = 48;
|
|
this.height = 48;
|
|
this.offx = -24;
|
|
this.offy = -40;
|
|
|
|
this.frame = 1;
|
|
this.count = 200;
|
|
}
|
|
|
|
@Override
|
|
public void moveImpl()
|
|
{
|
|
int z = this.frame;
|
|
|
|
if (z == 2) {
|
|
//cycle animation
|
|
|
|
if (this.flag)
|
|
z = 3;
|
|
else
|
|
z = 1;
|
|
}
|
|
else {
|
|
this.flag = (z == 1);
|
|
z = 2;
|
|
}
|
|
|
|
if (this.count > 0) {
|
|
this.count--;
|
|
}
|
|
|
|
this.frame = z;
|
|
|
|
for (Sprite s : city.allSprites()) {
|
|
if (checkSpriteCollision(s) &&
|
|
(s.kind == SpriteKind.AIR ||
|
|
s.kind == SpriteKind.COP ||
|
|
s.kind == SpriteKind.SHI ||
|
|
s.kind == SpriteKind.TRA)
|
|
) {
|
|
s.explodeSprite();
|
|
}
|
|
}
|
|
|
|
int zz = city.PRNG.nextInt(CDx.length);
|
|
x += CDx[zz];
|
|
y += CDy[zz];
|
|
|
|
if (!city.testBounds(x/16, y/16)) {
|
|
// out of bounds
|
|
this.frame = 0;
|
|
return;
|
|
}
|
|
|
|
// FIXME- the original code checks here for an ending condition
|
|
|
|
destroyTile(x/16, y/16);
|
|
}
|
|
}
|