Commit 4720134d58cd5fe0846ed911b360ed75641cb874

  • avatar
  • Bertram <bertram @ceg…el.net>
  • Thu Oct 22 01:18:41 CEST 2009
Fix flipping player's direction when using keyboard to walk diagonally.
  
575575 // Update the player sprite direction
576576 int direction = 0;
577577 const float dx = std::abs(dir.x);
578 const float dy = std::abs(dir.y);
578 float dy = std::abs(dir.y);
579
580 // When not using mouse for the player, we slightly prefer
581 // UP and DOWN position, especially when walking diagonally.
582 if (this == player_node && !player_node->isPathSetByMouse())
583 dy = dy + 2;
584
579585 if (dx > dy)
580586 direction |= (dir.x > 0) ? RIGHT : LEFT;
581587 else
  
302302
303303 const Vector &pos = getPosition();
304304
305 // Compute where the next step will set.
305 // Compute where the next step will be set.
306306
307307 int dx = 0, dy = 0;
308308 if (dir & UP)
342342 }
343343 }
344344
345 if (dScaler >= 0)
345 if (dScaler > 0)
346346 {
347347 //effectManager->trigger(15, (int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler));
348348 setDestination((int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler));
  
367367
368368 std::pair<int, int> getExperience(int skill);
369369
370 /** Tells the path has been set by mouse */
370 /** Tells that the path has been set by mouse. */
371371 void pathSetByMouse()
372372 { mPathSetByMouse = true; }
373
374 /** Tells if the path has been set by mouse. */
375 bool isPathSetByMouse() const
376 { return mPathSetByMouse; }
373377
374378 bool mUpdateName; /** Whether or not the name settings have changed */
375379