Wednesday, May 25, 2011

Gone Rogue Gets Road Ready

Road Trip Imminent
With moving day fast-approaching, it's time to start considering how operations will continue while in transit. My desktop will be in a box for a week or two, so I decided to give my old laptop a dusting-off and get it prepped for work on the road.

That said, my daily schedule is going to take a hit. It won't be full days of work for a while. It may only be an hour or so of tinkering here and there. I've decided I'll treat it like any other job, where relocation is partially a vacation, and I'll count part of it against time I can take off later in the year.

Laptop Prep
Getting the laptop geared-up turned out to be fairly painless. The Adobe Creative Suite I bought seems to have nearly installed without issue on the old machine. Just one Flash player hiccup which seems to have been fixed by manually reinstalling the player. And Adobe has a surprisingly nice arrangement for owners of the suite: dual-installs are allowed so that work can be done on a home PC and a laptop/work PC. They even run reasonably well on my old laptop!

MySQL, PHP, Apache, and MyPHPAdmin took about a half-day to get running. Again, a fairly straightforward process, with minor glitches. This time, it was getting the DLLs for MySQL to load, which required some Path Environment Variable tweaking.

With all that done, I fired up Flash, compiled the game, and contact!

Dropbox
Almost immediately, I started wondering about having source files, webserver files, and other game parts in two places. The old network/USB stick copying each time was starting to seem a little flaky for my needs.

So I've joined the modern world, and signed up for a Dropbox account. So far, I'm pretty impressed. I've got a folder on both my laptop and PC, and any changes I make to files in that folder on one machine appear in the other within seconds!

For now, I think I'll try working directly in that folder, and see how it goes. I'm skipping database syncing for now, but everything else is in there. So far, so good.

Snowfall
As one final treat before I leave, the game now supports snowfall!


Not quite as impressive without the animation. But the flakes are a variety of sizes, transparencies, and each move in a different frequency and amplitude. And what's more, the snow and rain animations switch based on the actual weather conditions!

There's more to add to weather, for sure. But I think it's already overdue for some housecleaning. Once I'm settled in again, I'll have to make the code a bit cleaner and more manageable.

Friday, May 20, 2011

Lovely Weather We're Having

We Have Weather Now
So the big to-do this week was adding weather. I want the game to have inclement weather so that it's in the player's interest to shelter against it (or have appropriate clothes). I want the weather to seem sufficiently real, but I also don't want to write a heavy meteorological system.

The compromise was to get some reasonable climate data (thanks NOAA!) for the game world, and write a simple algorithm to interpolate between winter and summer averages. It trends sinusoidally, with randomized variations, and includes temperature, precipitation, and cloudiness. Here's a glance:


If you click on the image, you can see it in more detail. In the top left corner, I've printed a description of the weather conditions, as well as the date. In the top right corner, you can see a UI element which depicts the sky. Originally, the weather was just that sky icon. But as it turned out, that wasn't a lot of real estate to tell the player what was going on. Particularly for something like rain, which barely showed up over the clouds in that UI image. Rather than expand the image, I decided I might as well make it intuitive, such that the player doesn't need to avert their eyes from the play area to know that it's raining. This was the result:


Some nice, old-school sprite rain! I also have a few icons setup for clear skies, partly cloudy, and day vs. night. Though again, the day/night cycle was really subtle with just that icon at the top. Once more, I decided to go nuts on intuitive UI, and wrote a day/night hex system. Which meant it was also time for...

New Hex Art
Astute viewers will notice that the hexes have changed a bit since last time. That's because I decided to give them a more pixel-perfect style, and did away with the shared border graphics. Now all hexes have painted borders matching their terrain type. I think the style is a step in the right direction too, as they look a bit more retro, and a bit less "whipped up in Flash."

These new hexes were created in such a way that it allowed me to easily create nighttime versions of each. I whipped up a nighttime color-shifting filter in Photoshop, and went to town. Here's the result:


Note the sky UI has also changed to reflect the time of day. I think day/night hexes will be a lot of fun to play with later, as I can add day/night images to hexes such as campfires or lights. I can also change things like the player's visual range and allow for powers like night vision at some point. The one hurdle I've encountered here is that water and plains are indistinguishable at night. That'll warrant some problem-solving.

Framerate
You may also have noticed a new framerate counter. Yes, it's finally time to start considering performance. These hexes were getting quite heavy to begin with, and with weather sprites flying around, it was getting pretty bad, pretty quickly. Part of the new hex design did away with separate border images overlayed on each hex. I originally thought that would make things easier to maintain, but it's not worth the extra draw calls with alpha images.

The big performance win turned out to be not drawing offscreen hexes. It sounds pretty obvious, but I was a bit surprised (perhaps naively so) that Flash wasn't doing this for me. I figured Flash was pretty good about culling anything offscreen, especially as it was such a mature platform. Not so. One fairly simple culling algorithm later, and framerate went from 8ish to 28ish. Fast map-panning and smooth raindrop animations!

There's more to come. I'm still planning on seasonal hexes (at least winter), as well as dusk/dawn. But it may be time to start tackling player status or load/save of maps. Though, there might also be some housekeeping in order after this big burst of output. I have some things to un-hardcode now that I'm more satisfied with the way things look/work.

Until Tuesday! (Monday's a stat holiday, so I've got the day off!)

Tuesday, May 17, 2011

More Databases, and Weather?

So, unfortunately nothing visual to show today. The last few days have seen some serious under-the-hood-type work instead.

Database Stuff
After last week's foray into the world of databases, it was time to use that newfound knowledge to get my game reading data from mySQL rather than hard-coded values. Getting flash to load data turned out to be a little tricky, as it was a non-linear process. It involved a lot of kicking off queries and listening for events signalling their finish. And with lots of data to load, that meant lots of disorganized listeners on my first draft.

After some rethinking, I setup a more organized DataHandler class which could dispatch queries to loader classes and store the results for the rest of the game to use later. Furthermore, I managed to simplify the game start-up process such that I could just list all the steps in one place, and let the DataHandler execute them in order, listeners and all.

The result? The hex types, their settings, and all game images are loaded from mySQL! It's pretty cool to be able to add data to the database now and not have to recompile. The closest I've been before was XML serialization routines in C#, which are also good, but I thought mySQL would be a better fit for lots of data writing.

Oh, and I managed to expand my database setup webpage to now include buttons for managing the game database, including recreating it based on the specifications in the php page. I was making enough changes to the database table structures that having this saved me significant time already. Guess the tech artist in me isn't retired yet :)

Other Bulletproofing
I also spent a bunch of time restructuring classes and methods to be more reliable, and more organized. Normally, I'd leave this for later, in the spirit of rapid-prototyping. But occasionally, one needs to do some housecleaning to make existing code easier to expand on for the next features. For example, I was rewriting code to handle getting the Hex under the mouse enough times that I decided to make it a method and be done with it.


Indie Life Continues
Still on the same daily schedule. The three 2-hour blocks are working quite well, and the afternoon grocery run with Rochelle is proving a welcome stretch and reinvigorator.

I'm managing to stay pretty focused too! Before I started, I was a bit worried I'd be one of those people who needs to unplug the ethernet to avoid stray browsing during work. But so far, I'm pretty on-it when I'm sitting at my desk. I occasionally stare out the window and watch traffic/people, but it tends to be while thinking of solutions to problems.

Next Steps
With that infrastructure work out of the way, I'd like to look into weather. The player is going to be struggling to survive against nature, so let's get some nature in there! I'd like to handle this a lot like the fog of war, in that it should be simple and only "seem" complex. Not exactly sure how I'll handle this yet, but I have a few ideas.

That's it for now. More to come!

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!

Tuesday, May 10, 2011

Day One as an Indie

Monday was my first full-time day as an indie. My original plan was to spend the first half of it coding, and the latter half doing smaller non-coding tasks. As it turned out, I spent over 80% of the day coding, and forced myself to stop late in the day to do some audio work. Got started about 9:30am, took an hour for lunch, went from 1-4, took a break to help Rochelle with grocery shopping, then spent another 5:15-6:45 stint before calling it quits. I'll give that schedule a few more tries, and tweak it as necessary.

Coding
The coding was largely spent on hex grid fog of war algorithms, with some quick-and-dirty perlin noise terrain generation to boot. I also spent a little time untangling some messy relative coordinate spaces I had created. Overall, Flash AS3 is still about the easiest game prototyping framework I've used yet, even though I loved C# and XNA. It can be arbitrary, and the IDE is a bit rough, but the support community is great, and most of the libraries I need to do stuff are already there and just work so I can focus on game logic.


Note: You can see an old top-down player sprite I created here as well. Yes, he is wearing a browncoat ;-)

Audio
The audio work included my first field test using my Zoom H1 audio recorder, at zero cost to development time. Hydro Quebec is doing some serious roadwork on our street this week. Since my office window faces the street, I was able to plop the recorder out on the sill, shut the window, and get about 1 hour of road work noise as I was doing other things. I have a lot to learn, of course, but it was fun picking diesel sounds, yelling laborers, and jackhammers out of the stream for use later. A little too much idle deisel noise to make most of it useful, though.



Day 1 - Conclusion
So far, so good. I was highly motivated all day. I had a few stumbling blocks where I couldn't bring my mind to bear on tricky problems, but I think that was largely due to needing to step away sooner and clear my head. I think I'll need more mini-breaks, where I get off my ass and walk around. I've found that worked very well for me in the past, but I need some time to work out excuses to stand up and stretch for a few minutes in this new work environment. I should also be more willing to switch gears and do art, audio, music, marketing, or business planning when the coding part of my brain needs a rest. And I'm really digging the feeling I can get right back in there today and follow-up on the stuff I did yesterday. It feels good to finally be making tangible progress on my dream!

Friday, May 6, 2011

So where's this game already?

A number of folks have asked just that question. More politely, of course. And it's a fair question. It's been about a month since my last day at BioWare. So where is this indie game already?

After quitting, I wanted to make sure I took at least a little time off before diving in. I needed a vacation, and it wouldn't do to start work only to burn out quickly. So I decided I'd take it easy for a while, get the relaxation out of my system, and approach things fresh and ready. Originally, I figured I'd wait until after we move to our new home. I wanted to avoid the interruption that is packing, moving across the continent, and unpacking.

But I'm starting to feel a bit antsy. With 4 weeks passed, and another 5 or so until I'm likely to be settled into our new apartment in BC, that's a lot of waiting. A lot of unproductive, antsy, audience-hemorrhaging waiting.

So I've decided to officially start Monday the 9th. It'll get interrupted by the move, unfortunately. But with most of my other big-ticket interruptions out of the way (filing taxes, finding a new apartment, visiting NH), it'll give me a few solid weeks' worth of time to kick-off development of my first indie game.

What will I tackle first? I haven't decided yet, but I have a few candidates. There's the game, of course. There are some prototype features I'd like to hammer out and test. I'd also like to look into user account solutions, for letting users save their progress online. There's purchase handling and virtual currency to look into, for when I'm ready to sell content. And there's also contracted artwork, company structuring (or not), and other infrastructure considerations to work out.

The game itself is definitely the forerunner. I'll probably spend 50% time on that, and alternate blocks of time on the others to keep things fresh and interesting. I'm not really sure what to expect in terms of productivity, as I've never developed games solo and full-time before. So what I'm able to get done in the next few weeks will help me better plan for the future. It'll also help me set the tone for working alone, such as what hours to work; how to break up the day; how I handle interruptions and distractions. I'm really looking forward to it. I'm on the doorstep of an exciting adventure!

> WEST OF DESK
> This is an open floor west of a game developer's desk.
> There is an empty seat here.
> A rubber mat saying 'Welcome to Indie Dev!' lies by the desk.

< Sit at desk.