Basic Enemy & Level Helpers


Fundamentally just implementing a basic enemy type into the level. It will automatically path towards the player and will move every time the player also moves. If the player and an enemy are on adjacent tiles after a move, this is considered a death/fail state. There's nothing to indicate that state currently, but all entities in the level will despawn and respawn back at their starting positions.

Spent a little bit more time last night working through how I was going to implement enemy pathing. Probably a good 40 minutes of figuring out the implementation and trying to mitigate  different cases where pathing might change or be suboptimal. Decided before actually writing any real code and trying to solve the problem that it might be worth seeing what the "Godot way" would be.

Turns out AStarGrid2D will do everything you need in a few lines of code. That's nice.

I'm glad I took the time to think through the problem and came up with a workable solution. I'm also glad I didn't have to implement any of it.

Otherwise, the majority of the work on this build was around cleaning up some of the level setup. Instead of positioning the player and enemies into the level, they're placed on load based on Marker2D nodes. I think that'll make the levels easier to setup and change around without having to pull in a bunch of scene and other business every time I want to make changes. Just drop a marker, set some metadata, and move on.

For the player or the (eventual) level exit, there should only every be one of each. I can address those by name. For the enemies, these are complete dynamic. Having metadata in the markers to indicate the type of enemy means I can have a base level that imports the different enemy types and populates the level based on the marker position and metadata. Seems like a reasonable enough solution.

Assuming I continue forward with the proof of concept build, I'll probably slap together a basic level data structure. This way I can load everything in the level based off a simple data structure. It'll mean creating a simple level editor/exporter, but that should make the process of creating, editing, and loading levels easier. Maybe it's more work than the project (and time frame) justify, but the whole point on this is to learn. It's my first game jam and I'm going solo. There's no glory here. Just incremental progress.



Files

game.zip Play in browser
1 day ago

Leave a comment

Log in with itch.io to leave a comment.