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

Method doBusSprite

MicropolisCore/src/MicropolisEngine/src/sprite.cpp:1337–1612  ·  view source on GitHub ↗

* Move bus sprite. * @param sprite Bus sprite. * @todo Remove local magic constants and document the code. */

Source from the content-addressed store, hash-verified

1335 * @todo Remove local magic constants and document the code.
1336 */
1337void Micropolis::doBusSprite(SimSprite *sprite)
1338{
1339 static const short Dx[5] = { 0, 1, 0, -1, 0 };
1340 static const short Dy[5] = { -1, 0, 1, 0, 0 };
1341 static const short Dir2Frame[4] = { 1, 2, 1, 2 };
1342 int dx, dy, tx, ty, otx, oty;
1343 int turned = 0;
1344 int speed = 0;
1345 int z;
1346
1347#ifdef DEBUGBUS
1348 printf("Bus dir %d turn %d frame %d\n",
1349 sprite->dir, sprite->turn, sprite->frame);
1350#endif
1351
1352 if (sprite->turn) {
1353
1354 if (sprite->turn < 0) { /* ccw */
1355
1356 if (sprite->dir & 1) { /* up or down */
1357 sprite->frame = 4;
1358 } else { /* left or right */
1359 sprite->frame = 3;
1360 }
1361
1362 sprite->turn++;
1363 sprite->dir = (sprite->dir - 1) & 3;
1364
1365 } else { /* cw */
1366
1367 if (sprite->dir & 1) { /* up or down */
1368 sprite->frame = 3;
1369 } else { /* left or right */
1370 sprite->frame = 4;
1371 }
1372
1373 sprite->turn--;
1374 sprite->dir = (sprite->dir + 1) & 3;
1375
1376 }
1377
1378 turned = 1;
1379
1380 } else {
1381
1382 /* finish turn */
1383 if ((sprite->frame == 3) ||
1384 (sprite->frame == 4)) {
1385 turned = 1;
1386 sprite->frame = Dir2Frame[sprite->dir];
1387 }
1388 }
1389
1390 if (sprite->speed == 0) {
1391
1392 /* brake */
1393 dx = 0; dy = 0;
1394

Callers

nothing calls this directly

Calls 2

clampFunction · 0.85
worldGetMethod · 0.80

Tested by

no test coverage detected