Still going strong with Map Generation

I haven’t had a lot of time to work on my map generator over the past week, but I feel like I’ve made some pretty solid progress.

I’ve changed the colors a bit… they should more closely match the colors used in the original Castle of the Winds maps. White is ‘ungenerated’, light grey is floor, medium gray is walls, and red is doors. Oh, yellow are places where connections ‘might’ get generated. If for some reason attaching a room at that point fails (collision with existing rooms, usually) the potential connection point gets removed.

This developer has gone 5 days without starting a new project.

Short update today, but I’m still plugging away at the Hex based dungeon crawler I started recently. I haven’t had a lot of time to work on the project since the last update… but in that time I’ve managed to make what I think is meaningful progress.

I continued work on trying to randomly place rooms and hallways on the hex grid, and I started to run into some issues around placing geometry and being able to tell where the walls go around the floor space. It got especially complicated around the seams between rooms/halls/etc. When I first started trying to build hallways, I created a method that would start at a given cell and then loop based on the desired length. At each step it would modify the cell as desired and then increment one of the coordinates. It worked… but was only really useful if I wanted to only do things parallel to the axes. That might be fine for now, but it just didn’t feel elegant.

I decided to step back and do a little rethinking and restructuring. I revisited the Red Blob article on hexes and wouldn’t you know it, there’s a whole section about drawing lines. I built some infrastructure, more or less following the methods they described, and, unsurprisingly, it worked out well. It was much more elegant than my previous approach, and it would work in arbitrary directions. Better still, it would simply return a collection of cells. Once I had the collection, I could perform checks on it, say, to look for collisions with existing geometry, or I could loop through and make whatever changes I want. Set it all to floors, set it all to walls, whatever.

To thoroughly exercise my new tools, I set up a quick experiment that would draw 30 random lines on my hex grid. Both endpoints were chosen randomly on the grid. Once I had each collection of cells, I’d check for collisions, and then set the cells on a few criteria. No collisions – everything is set to floor tiles. Any collisions – everything is set to wall tiles except the colliding cells – those are set to door tiles. The particular tiles aren’t important… just that they’re visually distinct so I can see what’s happening. This worked well, except it all happened more or less instantly. Great in that it indicates there aren’t any completely egregious performance problems… but it makes it somewhat hard to tell exactly what’s happening. Especially with 30 lines crammed on to a relatively small grid.

So, I spent a little time experimenting with Unity’s coroutines. After a little bit of work and a little bit of head scratching, I got it set up so that it would draw each cell one at a time and then wait for a short period of time. Because I was using coroutines, it would return control back to the main Unity loop and keep rendering new frames throughout the process. Voila! I could watch the lines draw out, including the different colors for the different things.

Ultimately, it really doesn’t seem like much, but it’s progress and I’m happy with it. Next up I’m going to rewrite the room generator to create them from collections of lines, and then get back to trying to connect hallways to them.

 

 

I’ve fallen off the wagon again. Or maybe I got back on the wagon? Also I’m bad at metaphors.

Hi. I’m Mirzero, and I’m a new-project-aholic. It’s been 3 days since I started a new project. I’m bad at finishing projects. A newer, shinier idea always comes up right when I’m struggling with an exceptionally uninteresting part of a previous project. I don’t think this is an uncommon situation in any kind of creative work, but it has gotten the best of me again. For example, now I’m writing a blog post about my new project, instead of actually working on my new project! Some part of me wants to show off what I do have, so far, though… perhaps it’ll help me stay motivated. Perhaps.

Anyway, the New Shiny this time around is hex-based maps. It’s an idea that’s been rolling around the back of my mind for a long time, but recently a few things have conspired to motivate me to do something about it. I’ve been inspired by several games; Civilization 6 and Hoplite are superb examples of the humble hex in action. I’ve also been inspired by other developers directly. Red Blob Games has a thoroughly exceptional article about all things hex that, though published in 2013, I only stumbled upon somewhat recently. Catlike Coding also has a more concrete exploration of hexes with a tutorial series around generating hex terrain similar to that used in Civilization. I’m not sure when this series started, but it’s still in progress.

All of these factors have come to a head recently, and I’ve decided that I want to work with hexes. Instead of building civilization managers, or tactical fleece recovery simulators, though; I’m aiming to build something closer to a dungeon crawler. A roguelike, though I’ve come to loathe the term roguelike these days. I’m saving some other, more complex ideas for the future.

In an effort to try and make this a project that I will actually finish, I’ve decided to try and start simple and more or less clone an existing game: Castle of the Winds. Aside from moving to a hex-based map, I’m trying to strongly limit the changes I make from the original. I’ve promised myself that once it’s complete I’ll go back and add all sorts of insane ideas I come up with along the way, but for now, simple is key. The UI will also probably change significantly, but only because it would be more work to emulate the Win 3.1 insanity than to build something simple with the Unity basics.

Borrowing heavily from the Catlike Coding tutorials, I’ve started to build out the procedurally generated maps. It’s extremely early days, but I can generate a map and throw a bunch of rooms on it:

So far, all it does is generate a bunch of rooms of somewhat random size and position, while ensuring that no rooms overlap, including borders. Grey hexes are walls, white hexes are floors of rooms, and blue hexes are the borders of rooms. The large blocks of blue that appear without a room in the middle of them are where the generator started to place a room but detected a collision and so abandoned it. The process is intentionally slowed down so you can kind of watch it happen… there is a 0.2 second delay between each room generation.

I also ‘wasted’ some time trying to figure out how to get a video of the generation that I could embed in the blog. Ultimately I used OBS (which I’ve used before) to capture the screen during generation. From there I used VSDC to edit the video; cropping it down so you only see the game window, and trimming the timeline to only show the generation process. I tried exporting to an animated .gif first, but no matter what I did (and I tried multiple tools) the quality was just garbage. Eventually I used the .webm exporter inside VSDC, and that has given me acceptable results.

Enough procrastinating; I need to go update the generator to put hallways between rooms. Perhaps I’ll actually write a post about that if I don’t get distracted by something else in the meantime. I wouldn’t hold my breath…

A rant on PHP

I’ll admit I’ve barely used PHP. I spent some time with it briefly at one of my first development jobs… but I was the only developer and it turned into a giant hackfest. I shudder to imagine the code I wrote back then.

A co-worker (who maintains one of our older applications which is PHP) was recently bitching about the language, and came across this article. I found it to be funny, and very accurate for what little I know of PHP. I figured it was worth a share!

 

Adventures in various programming stupidity

I came across this hilarious lightning talk by Gary Bernhardt quite a while ago. I foolishly started watching it at work and couldn’t contain my laughter. Other developers started giving me dirty looks so, of course, I sent it to all of them. Within minutes the entire department was nothing but chuckles.

I came across it again recently, and decided I should post it here!

 

 

 

 

Welcome to Mirzero.ca!

I’m a software developer by day, and a gamer by night. I’ve started experimenting with game development and game streaming.

You can check out the game I’m working on (working title: Legion) here: http://mirzero.ca/Legion/

You can check out my game streams live at twitch.tv/mirzerotv/ or recordings on YouTube at https://www.youtube.com/user/MirzeroTV