Latest Fixes: Pathing for Pixel-Accurate Movement

Today was focused on getting the monsters to behave as intelligently as they did back when movement was tile-based.

  1. Monsters uncrowd when they are overlapping (should pretty much never happen in general, but sometimes they spawn in the hitbox of another creature). If an intersection is detected between two creatures, they get an override that compels them to move away from each other for a few frames.
  2. Cardinal directional movement replaced with simple vectors, to allow for diagonal movement.
  3. When monsters have a line of sight and can walk directly to a hero, they use 8-way movement to get there. I added a bit of tolerance to the check to prevent the monster from zigzagging when on the same X or Y coordinate.
  4. Without line of sight, the monsters fall back on pathfinding (that is, if the monster is intelligent enough.. more on AI changes in another post). Just like with direct walking (which I call Gauntlet Movement in the code), it uses 8-way movement. This was really easy to do with my existing path mapping: it just checks the 8 adjacent tiles by including directions, rather than only the 4 adjacent tiles in cardinal directions.
  5. When monsters are in melee range, they can attack in 8 directions.

A quick word on diagonal movement. In many games with two-dimensional movement, the X and Y movement vectors simply get combined, and not adjusted for the trigonometry. Bishop movement becomes unnaturally faster than rook movement in this case. Think Doom II or Secret of Mana.

Traditional diagonal movement just combines X and Y to give you this nice diagonal reach.
Traditional diagonal movement just combines X and Y to give you this nice diagonal reach.
The "proper way" to do it adjusts diagonal movement to about 70%.
The “proper way” to do it adjusts diagonal movement to about 70%.

After spending so long with these games, my adjustment to trim diagonal speed actually feels like a real debuff. It seems slower even though it’s the same speed. For now it’s still in there, but I’m not sure what I’ll do later. A friend suggested the fast diagonal movement be a powerup.