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

Method turnTo

micropolis-java/src/micropolisj/engine/Sprite.java:212–227  ·  view source on GitHub ↗

Helper function for rotating a sprite. @param p the sprite's current attitude (1-8) @param d the desired attitude (1-8) @return the new attitude

(int p, int d)

Source from the content-addressed store, hash-verified

210 * @return the new attitude
211 */
212 static final int turnTo(int p, int d)
213 {
214 if (p == d)
215 return p;
216 if (p < d) {
217 if (d - p < 4) p++;
218 else p--;
219 }
220 else {
221 if (p - d < 4) p--;
222 else p++;
223 }
224 if (p > 8) return 1;
225 if (p < 1) return 8;
226 return p;
227 }
228
229}

Callers 3

moveImplMethod · 0.45
moveImplMethod · 0.45
moveImplMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected