I had one week where I couldn't do anything.
But I did few things last week. Floor generation mostly that showed how many problems there are (well, were) with room generation. Were, because I fixed them this week, but I'll write about that here.
Room generation now creates walls, doors and floor (which was not present in original game). There are two ways to generate floor:
But I did few things last week. Floor generation mostly that showed how many problems there are (well, were) with room generation. Were, because I fixed them this week, but I'll write about that here.
Room generation now creates walls, doors and floor (which was not present in original game). There are two ways to generate floor:
- Start with boundary pieces, attached to walls, then fill rest with "tiles".
- Fill everything with "tiles".
Tiles are not actual tiles, they are just pieces as anything else, so they don't have actually to tile :) This looks simple as an idea, but I really couldn't decide what to do with this, as I wanted to have floor connected to walls but at the same time, I wanted to have lots of pieces filling floor. Solution now seems obvious but it wasn't few weeks ago.
There are also starting pieces that land right in the middle of line closest to camera in the room that can limit tiles in nice way. I still need to add code not to clip them, so they can extend down in nice way.
And now bad things: when I run it (and it finally worked, as there were few minor issues, one of them related to my incorrect use of vala :( with c++ I would not do such thing in first place and I am more and more tempted to switch to c++) it took more than half a minute to generate 7 rooms. More than half a minute. That's way too long. I was logging a lot, so I cut some logs to be optional and it was still too long. I compiled without logging and debug info and it turned out to generate in less than a second (I didn't even try to measure it).
Why it was taking so long? I don't exactly know. I know that I did lots of things completely unnecessary. When room generator added new piece, its location was updated and then madness was beginning. Every piece was disconnected from each other and then reconnected basing on their location. And everything was checked if it intersects with each other. And while for walls and doors there were maybe 20 elements top, with floor it started to be 60 and most of checks were done against each other. Twice (because I was too lazy to do it properly in first place). I changed it to only do most of that stuff for last element added.
I did that to properly rebuild connections when something is removed and for removing pieces it still goes through that madness. But here's why. Some of connectors might be closed due to state of other connectors and while they are being closed when something is added, it seems to be fine, but when something is removed, it is much more trivial to disconnect everything and rebuild it. Of course it isn't right way and if I find room generation working too slow, I might decide to change that. But as it works now and there's no need to do anything more complex, I'd rather keep it as simple as possible.
What's for next (well, this) week? I'd like to add foreground and background generation and introduce subtypes for rooms. For now, without properly choosing them for map - this will have to wait for next milestone.
I hoped to do more during last few days but: a) I started to get addicted from War Thunder and already spend 30 hours flying - which is great way to relax and round time that lasts up to 30 minutes seems to be better choice to spend limited amount of time than coding, as this can easily extend to few hours. But then, after each round I have "one more" issue :( b) I actually didn't spend too much time next to computer, and when I did, I had other stuff to code (book-keeping app that recently made it possible for us to get rid of mortgage but as we want to keep some money just-in-any-case and maybe start a little business, we still have mortgage) c) we were going to restaurants almost every day last week and it was great :D and we should do this now, as soon we're going to have baby and with such small fellow we won't be able to go to few places for some time.
No comments:
Post a Comment