MCPcopy Create free account
hub / github.com/SimHacker/micropolis / doTornadoSprite

Method doTornadoSprite

MicropolisCore/src/MicropolisEngine/src/sprite.cpp:1234–1294  ·  view source on GitHub ↗

* Move tornado. * @param sprite Tornado sprite to move. * @todo Remove local magic constants and document the code. */

Source from the content-addressed store, hash-verified

1232 * @todo Remove local magic constants and document the code.
1233 */
1234void Micropolis::doTornadoSprite(SimSprite *sprite)
1235{
1236 static const short CDx[9] = { 2, 3, 2, 0, -2, -3 };
1237 static const short CDy[9] = { -2, 0, 2, 3, 2, 0 };
1238 register short z;
1239
1240 z = sprite->frame;
1241
1242 if (z == 2) {
1243
1244 /* cycle animation... post Rel */
1245
1246 if (sprite->flag) {
1247 z = 3;
1248 } else {
1249 z = 1;
1250 }
1251
1252 } else {
1253
1254 if (z == 1) {
1255 sprite->flag = 1;
1256 } else {
1257 sprite->flag = 0;
1258 }
1259
1260 z = 2;
1261 }
1262
1263 if (sprite->count > 0) {
1264 sprite->count--;
1265 }
1266
1267 sprite->frame = z;
1268
1269 {
1270 SimSprite *s;
1271 for (s = spriteList; s != NULL; s = s->next) {
1272 if (s->frame != 0 &&
1273 (s->type == SPRITE_AIRPLANE || s->type == SPRITE_HELICOPTER
1274 || s->type == SPRITE_SHIP || s->type == SPRITE_TRAIN) &&
1275 checkSpriteCollision(sprite, s)) {
1276 explodeSprite(s);
1277 }
1278 }
1279 }
1280
1281 z = getRandom(5);
1282 sprite->x += CDx[z];
1283 sprite->y += CDy[z];
1284
1285 if (spriteNotInBounds(sprite)) {
1286 sprite->frame = 0;
1287 }
1288
1289 if (sprite->count != 0 && getRandom(500) == 0) {
1290 sprite->frame = 0;
1291 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected