Friday, May 13, 2011

Indie Life, Fog of War, and Databases

Indie Life
So, work continues on the prototype. Both the past two days were structured pretty much like the first. Morning block, then lunch, then afternoon block, then 1 hour break, then evening block. I end up finishing about the same time I did at BioWare, since the extra break replaces my old commuting time.

I also make it a point to try and get up about once per hour. I've read ergonomic material suggesting that was a minimum to aim at for healthy workplace habits. I've also noticed that standing/walking around tends to jog my brain back into action, especially when I get stumped during a long sitting spell.

Coincidentally, weasello recently tweeted a timelapse of himself at work, where he does just that! When I asked him about it, he said it was inadvertent. But he also pointed out a long shower is the perfect solution to a paralyzing mental block. I totally agree!

Fog of War
I've get fog of war working pretty much the way I want it to now. It works a lot like the Civ 5 model, where the player can see a certain range, and some tiles block line of sight. Hills increase visual range over everything except other hills, and mountains block everything.

At first, I thought Civ had a more complex elevation-based line of sight model. I was delighted when I discovered some XML settings which suggested a simpler (albeit more clever) design. Here's a screenshot of it at work:


In the screenshot, you can see the player standing at the edge of a forest. His visual range is 2 hexes across the plains. But the tree hexes block that vision, limiting it to 1 hex instead. Lastly, the dimmed forest hexes in the northeast show areas the player had previously explored but which are now out of visual range. Careful observers will note the player had a 1-hex visual range while travelling through the forest. Also, they'll notice the awesome programmer art I've used in the hexes!

Databases
One of the tasks I earmarked as higher priority was to get my game using data-driven design asap. I got a certain way into the code just using variables set at the headers of .as files, but that won't scale well. And I'm getting to the point where I need to save data between sessions anyway.

Rather than spend time researching how to get Flash to parse data from text files, and write back to them, I decided to use that time to research databases and Flash. I'll have to do it someday, might as well do it now.

So Wednesday was mostly spent getting the environment setup on my home PC. In order of installation, that includes Apache, PHP, MySQL, and phpMyAdmin. On Windows 7, it was mostly straightforward. The one gotcha turned out to be Win7's Program Files (x86) folder and Apache. It took me a little over an hour to figure out why the config changes I was making wouldn't stick. Turns out, Win7 protects files in that (x86) folder in a funny way. It warns me I need admin rights when I try to change a file in that folder, which I am given the option to temporarily grant myself. Then, it saves my changes.

Or so I thought. When I open the config file I edited, I see my changes. Plain as day. But when I restart Apache, no changes. And here's the weird part: make a copy of that config file, and the copy has no changes. Open the original file, changes are there. Wha?

On a hunch, I copied the file outside of (x86) and made my changes there, then copied back into (x86). And it worked! I still don't know what mechanism Win7 used to simultaneously protect that file, but trick me into thinking I had changed it. And I don't have the patience to dig further right now. Maybe I'll untangle that ball some other day.

The rest of the day was spent building a working knowledge of MySQL queries, database design, and PHP interaction with MySQL. At the end, I had build myself a PHP script which reliably created the tables I'd need to store map data. Next step: get that data saving and loading from Flash!

Audio
Oh, I also got a few more samples recorded. For one thing, this awesome vehicle with a shovel and tank treads showed up! Yay screeching tread noises! And I managed to get some ambient park noises to boot. Critters, distant car horns, and the murmur of city all around. Oh! And late-night recordings of cars passing over steel plates in the road.

Ok, off to MySQL land!

2 comments:

  1. Uner Win7, Check your My Documents folder or %APPDATA% for the modified file, it might be in there as way of Win7's file protection system.

    ReplyDelete
  2. Hey Brian! Hm, didn't see the file in either of those locations. I'll probably have to dig into Win7's UAC to get to the bottom of it. But for now, it works, and I'm content to leave it that way until it presents problems ;-)

    ReplyDelete