We’ve Achieved High Resolution

I could post a screenshot, but you wouldn’t be able to tell the difference… but today was entirely focused on getting ready for the move to HD. I have decoupled the tile pixel dimensions from their world dimensions. With the change of a single line, I can set the world up to use tiles of any size (32×32, 24×24, or 64×64 like Escape Goat 2). The move speeds and hitbox dimensions are calculated independently of this.

I still need to figure out a good native grid size: how many tiles are visible on screen at once. Soulcaster II had a visible size of 22×16 tiles. I’ve currently got the tiles scaled to 40×40 pixels, which at 1280×720 gives me a maximum visible grid of 31×17.  Here’s what that looks like:

maxsize_31x17Right now that seems a bit larger than I want. Bringing in the width a bit, here’s 29×17:

29x17A bit more manageable, and I think the aspect ratio is a little nicer.  Narrowing it a bit more, to 27×17:

27x17The beauty of this game being procedurally generated is that I don’t have to decide on a visible tile size (default room size) right now. I can make patterns of a variety of sizes, and have the game arrange them in larger rooms. Since the game will have scrolling in two dimensions, there will be some enormous rooms, where you can’t see all the enemies and obstacles at once.  The engine also supports variable room sizes, and will center the room in the viewport with optional zooming. (Escape Goat 2 did this, and would zoom in up to 25% larger than default size).

Switched to Integer Math

I was planning for the refactoring of the coordinates system to take two full days, and I am already done with it. I needed to move from floats and Vector2’s to my own fixed-point based structs for position and velocity. I’m a huge fan of integers, and now the Soulcaster engine uses them just like Escape Goat.

World coordinates are now independent from pixels, so I can boost the resolution to HD, and even try a few different tile sizes. I still haven’t figured out what the best visible room size is yet. I might have a bit of zoom like EG2, but there should be a max size that fits the whole screen.

Off The Grid: Research Complete

After a quick rewrite of the collision detection system, and a couple extra AI systems that aid in pathfinding (more on that in a future post), I’ve got the monsters working just how I need them to.  Even with a super fast spawn rate, they don’t overlap, and if they get deadlocked trying to get into a doorway from opposite directions, they will back off after a moment and retry.

With omniscient pathing turned on, the rats are completely unstoppable.
With omniscient pathing turned on, the rats are completely unstoppable.
This is with pathfinding disabled, and AI set to move Gauntlet style (always towards the player).
This is with pathfinding disabled, and AI set to move Gauntlet style (always towards the player).

Pathfinding Test With 30 Rats

Pathfinding is operational. The rats intelligently pick new routes to flank the player and avoid congestion in the long term. What they don’t do very well yet is avoid clogging up the doorways when they’re already bunched up. They also unnecessarily zigzag a bit, slowing them down and making them look just a bit more insane.

I have an idea I’m going to try tomorrow that might fix the clogging around doorways. The monsters will have access to a traffic map that tags each tile with a movement vector. They all start out neutral, and when a monster moves into a tile, that tile’s vector is set to match the same direction as the monster’s movement. When inside a tile, a monster has to move along with the current, or vacate the tile. Currents get reset with a timer, so if a monster hasn’t walked on the tile for a few frames, it gets neutralized.

It’s an unusual system, so I don’t know if it’ll work yet, but it’s worth trying.

To fix the zigzagging, I can set the monsters to keep a course for longer. Once they are in sight range of a hero, though, the zigzagging will stop because they stop pathing altogether at that point.