Devlog: Spawn Radius
I’m about to get back into development on Sverdheim, so to warm up, I’m going over my old development notes, which I’ll be posting here. If you follow me on twitter, you have probably already seen all of this.
In this gif, I’m working on the spawn radius for enemies. Initially, Sverdheim took place on a small, finite board. So I was able to just generate some random coordinates that weren’t too close to the player and spawn mobs there.
Then I changed the world to be infinite in size. You start off in the center of a grid of hexes. Each chunk is 16x16, and there can be as many chunks in every direction as there are signed integers. So you have a lot of space to move around in and explore!
But that means I can’t spawn mobs just anywhere. It only really makes sense to spawn them near the player. I plan to have a limited view radius around the player too, so we can spawn just outside of that (and despawn if a mob falls out of an outer radius.
To calculate where a valid space for a mob to spawn, I create a list of coordinates using Bresenham’s circle drawing algorithm. Despite being written for a square grid, it works more or less as good on a hex grid as well.
To help me visualize that during development, I highlight those potential spawn hexes in red when the spawn is triggered. That visualization will go away for release, but by doing this, I got to verify that the coordinates made sense on a hex grid. It also allows me to tweak the size of the circle. I can test, and if it’s too big or too small, then I can just change the public value I’ve exposed for the circle’s radius in Unity.
You can kind of see towards the end of the gif, I turn off the red highlight for a second, and reveal the one hobgoblin that has spawned in the northeast side of the circumference.
Get Sverdheim
Sverdheim
A roguelike game in a procedural world with generative music.
Status | Released |
Author | benfranklinstein |
Genre | Role Playing |
Tags | Casual, Exploration, Fantasy, Perma Death, Pixel Art, Procedural Generation, Roguelike, Short, Singleplayer, Tactical RPG |
Languages | English |
More posts
- Devlog: Colored AssetsFeb 28, 2021
- Devlog: More Progress on AssetsFeb 23, 2021
- Devlog: Creating AssetsFeb 22, 2021
- Working on SettlementsJun 13, 2020
- Version 1.2.0 Release: Character CreationMay 29, 2020
- Version 1.1.0 Release: Infinite DreamsApr 30, 2020
- More WritingApr 24, 2020
- How to Start AgainApr 07, 2020
Leave a comment
Log in with itch.io to leave a comment.