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

Method turnTo

MicropolisCore/src/MicropolisEngine/src/sprite.cpp:391–420  ·  view source on GitHub ↗

* Turn. * @param p Present direction (1..8). * @param d Destination direction (1..8). * @return New direction. * @todo Remove local magic constants and document the code. */

Source from the content-addressed store, hash-verified

389 * @todo Remove local magic constants and document the code.
390 */
391short Micropolis::turnTo(int p, int d)
392{
393 if (p == d) {
394 return p;
395 }
396
397 if (p < d) {
398 if (d - p < 4) {
399 p++;
400 } else {
401 p--;
402 }
403 } else {
404 if (p - d < 4) {
405 p--;
406 } else {
407 p++;
408 }
409 }
410
411 if (p > 8) {
412 p = 1;
413 }
414
415 if (p < 1) {
416 p = 8;
417 }
418
419 return p;
420}
421
422/** ???
423 * @todo Figure out what this function is doing.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected