Update 10: Pathfinding, Lighting, and a New map!


Hi Folks! I can't believe it's been a month since my last update, I must be slacking! Well actually, we're definitely not slacking, far from that even. Less frequent updates recently has translated into more work on the game itself which can't really be a bad thing. I'm also still trying to find my pace update-wise and I think I'll likely land right around the 3-week mark for each update cycle. Seems to reflect the length of a strong development iteration for us.

Anyways, here's what's on the menu of this update today

  • improving mouse motion and collisions handling - adding "smart" pathfinding for both player and monster entities
  • experimenting with light effects on a brand new map & map theme (likely to become a "sewers" environment)
  • a zoom feature (and what that entails gameplay wise)
  • a couple of new soundtrack drafts and the publication of a first version of our website

So one of the things that still sucked pretty badly with mouse motion was that when you'd hold & drag, it would only reflect the range of motion available when using the keyboard's directional arrows. I'm not certain why I did it like that initially, I guess it was in an attempt to keep things symmetrical or "equal" which is kind of stupid since you could still point & click to a specific location anyways, it just wouldn't work when you kept the mouse button down and kept dragging your character around (in this case, you'd be going straight into the diagonal & orthogonal directions). Anyways, that's now fixed. You can move around freely in every direction with the mouse.

Image attachment

The changes I've made to mouse-driven motion go far beyond this (albeit small) adjustment though. I've poured about 2 weeks of work into a complete overhaul and upgrade of my collision handling, in particular what I initially called "bouncing" or "sliding" in my code. That is, the way your character reacts when something gets in the way (a wall, a prop, a monster or another player). That stuff ended up being pretty hard, I must say. A few months back, I started nonchalantly coding systems which manage things like acceleration, velocity, and other physics-related stuff myself without realising just how complex this stuff would become once various things start colliding with each other. At the time, I didn't know about libgdx's box2d extension either, which is is a full blown 2D physics simulation engine. It would have certainly come in handy at the time. During this two-week push for improved collision handling, I hesitated a couple of times and almost scrapped all of my physics-related systems in favour of a re-write on top of box2d. However, I eventually managed to get things to behave and I am now confident in both my understanding of the problem's space as well as the home-cooked solution I ended up implementing to address it. For brevity's sake, I'm not going to talk about all of these issues at length here, I'll just say that along the way, I upgraded to elliptic surfaces for representing body "footprints" on the ground, added discrete sensors, and ended up designing a fairly comprehensive visual debugging toolkit for my collision sensors and avoidance systems as you can see in the screenshot above.

I eventually refactored the systems involved, decoupled a bunch of stuff and started applying similar principles to being-on-being collisions, as you can see here:

Image attachment

I did end up getting a few headaches due to various corner cases such as this one in which sensor granularity can't really ever be high enough (well, it's discrete for a reason I guess..) to prevent the entity from overstepping a wall tile, especially if you scale sprite sizes up:

Image attachment

But at this point, I'll gladly say that running into walls or any other kind of obstacles makes for a pretty smooth and, in my humble opinion, more than acceptable player experience. Moving on: another big addition is "smart" pathfinding, which now helps navigating most mouse clicks around obstacles and gives monsters a much better chance of closing the gap with a player while in combat:

Image attachment

You can see an early live version of the algorithm in action here:

A* Pathfinding demo video on Youtube

This is kind of a big deal in terms of making the overall experience of navigating a map smooth (gets rid of 95% of wall collisions when moving using the mouse). But I really don't regret investing time into proper wall collision handling because it still benefits keyboard motion entirely, and provides a solid safety net for when pathfinding fails or is undesirable (there are more cases than you might think which fall into that category actually). Moving on to something I've been super excited about lately: we've added the first bits of dynamic light sources in the game. For instance, torches now effectively light up their surrounding environment and the character has a bit of a glow surrounding him/her which helps players see stuff in the vicinity better. More importantly maybe, it adds contrast gives depth to the whole scene due to the fact that there is now a darker ambient light by default on the map. We also have a brand new tile set which will probably be representing a sewers area in the end. You can check this out on the following screenshot:

Image attachment

More importantly maybe, it adds contrast gives depth to the whole scene due to the fact that there is now a darker ambient light by default on the map. We also have a brand new tile set which will probably be representing a sewers area in the end. You can see a number of new props on there: barrels, boxes, bones, etc. I personally love this map and can't wait to see the next iteration.

Image attachment

I don't know what you think, but I think it's starting to come together from a visual / artistic standpoint! Next up is a zoom feature and the support of fullscreenmode, custom resolutions and automatic resolution detection. I'm not completely certain as to why I implemented the zoom in the first place -- and it wasn't a huge investment by any means anyways thanks to libgdx's viewport system -- but I just knew I kinda wanted it. Now I realise that it has certainly helped me debug stuff like monster aggro range (when zoomed "out") or collision bugs (when zoomed "in"). I even think I should have done it earlier.

One of the reasons against doing it initially was that I planned on doing something like in Diablo 2 where you can't mess with stuff outside of your screen and a lot of behind-the-scenes optimizations are possible because of the lack of zooming and screen-shifting. However, I think we'll be going a different route in our project and instead of cutting corners for performance reasons, I'll try to support visualising the entire map at once via zooming (assuming it's been explored, since I'll add Fog of War soon). That'll make for some super interesting gameplay once the adventure tree gets implemented (more on that note in future updates, you'll see what I mean) and might resemble the experience of map management in god PoV games such as city builders, RTS or sandboxing games (Supreme Commander, Factorio, etc). So this is what it currently looks like in debug mode when you zoom out, although a single screenshot here doesn't really do the feature justice:

Image attachment


To close this out and change the subject to something a little different, I've put up a couple of new audio exports which will possibly make it in the final soundtrack after they get reworked and remastered for background music purposes. These are pretty loud or high tempo tracks which will likely be used for boss situations or such. Sound-wise, I'll try to add a couple of new sound effects soon and start working on more chill / ambient / atmospheric tracks as well. Here are a couple of links for those who are interested in listening to these:

Fractal Rollout audiotrack on Soundcloud

Trenchcoat Hero audiotrack on Soundcloud

On a quicker, unrelated note: I also threw together a basic website so that it'd be easier to talk to people about the project. It gives us this main "anchor" we needed but we're still not ready to really promote or discuss the project publicly yet.

Link to the official Project Visionaries website

And that wraps it up for this (relatively) large update. Hope you'll enjoy reading about our work and I'll catch you on the flip side!

Leave a comment

Log in with itch.io to leave a comment.