Controlled Doses of Exceptional Blather

Thursday, April 30, 2009

Smooth Sailing... Not On My Watch

It has not been a pleasant week. I've been feeling under the weather since Sunday. Probably a combination of the change of season and the fact that I worked like mad late last week. I'm still not feeling all that zippy and I'm going to be working like mad once again starting today... hopefully I don't die. :P

So I decided that I would pursue Physics after considering my options at The Fork (see last entry). Not only would it be fairly simple to put in place (afterall, I had Farseer available, I'd used it in the past and was somewhat familiar with the way it worked, and I didn't have all that many objects in need of physicality just yet...), but it would impact the way I approached some of the other items in my to-do list (level design mostly). I'm nearly done with it at this point, but it hasn't been without it's difficulties.

On a side note quickly, I can sum up my impressions with Farseer in one word: Wow! I guess I'd forgotten how functional it was. But it's also progressed since I used it last. I downloaded all their samples and ran them all and it's quite impressive what the engine can do. It's overkill for my game, but that's just better... I'm provided with this lightning fast, easy to implement, and very stable engine without having to worry about any sort of design of my own (aside from figuring out what physics to give all my objects). Not only that, but perusing it's code kind of opened my eyes a bit to some sloppy choices I've made for my own code lately. They've gone to great lengths to optimise their coding, and I've been pretty obsessive lately about doing so also. It's been very educational.

Progress
Over the past week, I've implemented Farseer Physics to my project. I've set up object pools to speed up the generation and disposal of enemies and bullets. I've allowed for the player, enemies, and bullets to make use of physics. I have not gotten them moving and colliding just yet, but it should be a fairly easy undertaking. I've been derailed somewhat by trying to implement the Farseer Debug View class. This draws overlays for all the physics objects. I've implemented it alright actually, it's really quite easy, but what hasn't been easy is getting it to transform coordinates properly according to the position and zooming of my camera. This is still a work in progress.

Up And Coming...
  • Fix the physics debug viewer.
  • Work on moving the physical objects around and handling collision.
  • Change the player input/AI so that it adds forces instead of manually rotates or accelerates
  • Dispose of bullets when they impact with hostile target
  • Spawn explosions
  • Maybe particles??
  • Track damage
  • Kill/crash enemies
Ohh, and I downloaded a myriad of fancy tutorials and samples for special effects. Before I move on down other huge involved aspects of project, I may put some time into beautifying things a bit. :D

Friday, April 24, 2009

The Fork In The Road

Oy vey, it's been a pretty crazy week already, and I still have 2 days of work to go. Fortunately, I've been able to balance my work load with just the right amount of fun time to keep my mental and physical stability in check. I've played guitar, played some WAR, done some coding... sadly, the coding hasn't gone too far too quickly. It's become a real beast and now I've come to that fork in the road... I'm been working with some small scale stuff up til now. The organization was a beast, but that's aside now. I've got the controls working and the enemies working and the weapons and guns and all that... at least superficially, but now... now I've come to a crossroads. From here on out, what would really benefit me the most are the large components of the game. What good are flashy guns if they don't impact things? What good are flashy bullets without the fancy muzzle flash and animation associated with it? What good are ships flying around if they can't effect each other? All these depend on large scale functionality so the time has come for me to dig in to these.

Allow me to list those larger scale things that I feel I must tend to now or soon to progress my game:
  • Physics - Need this for my bullets to hit things, to restrict movement, to crash, to smash. Don't really see this as being a minor undertaking, or something that can be done in small increments. It's pretty much all or nothing. However, I think I've just about decided to integrate an existing solution... Farseer. It's 2D. It's come a long way since I used it last. It's finely tuned. It's fast. It's fairly easy to integrate, though it will take a decent chunk of time to do so.
  • Sprites - Need to allow my sprites to attach various optional Parts. This would allow me to attach a muzzle flash to the player ship when he fires his gun(s). These need to be able to be drawn if necessary and not, if not. Also, need to set it up so that the ship's movements are reflected in it's thrusters. This will also require special consideration for how and where they're attached and how they're drawn and animated when required. The multi-Part aspect is all setup already, but I need to allow them to be optionally drawn, optionally animated, and swap-able with minimal impact on appearance and performance.
  • Animation - This ties in deeply to the previous item. My multi-part sprites must be animated. This is also no small undertaking and I don't see this as being something that can easily be broken up into tiny pieces. Like Physics, it's also all or nothing. Fortunately, I don't see a need for too complex animations, but even to get simple ones going is a real trick. To top it off, I think I'll need to create a toolkit or editor to set up the animations. I've done much of one already I can borrow from which will make it easier, but it's also a time consuming endeavor, and also the step of development that I've crapped out on in previous projects.
  • Map - Sooner or later I'm going to need to flesh out what constitutes my levels. This will have to go hand in hand with the physics implementation, as the levels will dictate where the physical landscape exists. This will also require an editor and will also require a great deal of work. However, I do have much of an editor complete already so I'm halfway there. I will probably leave this for later, as my current test-level will be sufficient for the time being.
  • AI - Finally, the always present looming challenge of AI is there. This is a large undertaking, but fortunately, is one I can get away with doing in smaller chunks and with smaller finer tuning. Does this mean I should tend to this before tackling the huge undertakings? Your guess is as good as mine.
So I've got many choices ahead. What will benefit me the most the soonest? How do I prioritize things that are equally important? What might serve best to aid the creation of the following components? How should I tackle what I inevitably decide to pursue first without getting burnt out too deeply into it like I have in the past? I guess I'll keep you posted. :P

Monday, April 20, 2009

Strategic Disarray

No hard work comes without it's sweat. If the American revolutionaries hadn't perceived the majesty of what could be, and deemed the sacrifice required to attain it worthy of the End, then what would have come of so productive a nation? Bodybuilders don't get where they're at without a world of pain and sweat and sacrifice, and none of that stuff is fun...

I'm currently neck-deep in a tangled mess of coded treachery of my own design, trying to untangle the threads into something vaguely resembling order. Lucky for me, I actually enjoy the painfulness of it all. No, I'm not a masochist, I can just recognize and appreciate the painlessness of my pain. I'd much rather have to untangle 10,000 lines of code into some semblance of order than break my back building muscle... but then... maybe bodybuilders think the same way in reverse... (hrm... do bodybuilders think? ...hehe, I keed).

While it hasn't happened everyday, I have managed to find a couple days this past week where I was in just the right frame of mind to dig into the tangled web of disorder I've knit and do a little rearranging. This "right frame of mind" is hard to explain, as it's mostly just some sort of ability generated from the right mix of caffeine, sleepiness, boredom, and duty that allows me (dunno if I'm unique here or if it's possible for others to attain) to turn into a thoughtful, plotting, organized zombie of sorts. There's a mindlessness to it. I am nothing but thankful for whatever provokes me into this uber-productive all-understanding state, as I've managed to accomplish crazy things this past week.

Progress
I've been lost in a morass of organization and modularization of my projects. I've faced a massive lack of communication between my logical objects (ships, bullets, etc) and drawn objects (the sprites themselves). I've dealt with the enormous task of defining what constitutes a player or enemy... what constitutes their weapons, and how to allow them to interact with bullets of any given description to accommodate my goals... and a myriad of other things I would have thought at a glance to be hopelessly complex and time consuming. And yet, in the end, a couple weeks later I've got quite a nice framework to show for it! Unfortunately, it doesn't really show... yet... but it will allow for smooooth truckin' now. Why, last night I even got bullets to zip across the screen from my ship! Yeah, I know it's crazy. That was, actually, my goal of a few blogs back I think, but the path to get there was riddled with a hundred potholes and detours I had to traverse.

Hard Part's Over...?
I have guns, now I need to tune them! The bullet spawn slightly off-center. The guns don't have burst animations or anything (though I've already found quite the lovely sprite for this already) yet. What about bombs? What about explosions? What about missiles? What about different rates of fire, and dealing damage, and ricochets??!??!??!??!?! HUH?!! Well, it's all on in the plan. Ohh, and what about my crazy broken AI? I need to fix that too. I overhauled the whole enemy ship hierarchy... I overhauled pretty much everything... and it's working better so I think my AI will work better too... some day soon.

Tuesday, April 14, 2009

Hello World!

No, I haven't scrapped my game in favor of a whole new one again... Nor have I stripped down to a state of absolute simplicity. But, I've been without Internet access all week in the office and so have felt like an outcast. Funny, I had always thought that I wasn't so dependent on being "wired", but it felt like I had lost touch a bit. Ohh well, in the mean time I've made some excellent progress on my game I think...

Progress
Seems as I left things I was floundering around with some spotty enemy patrol AI. Well... my enemy patrol AI is still far from where it needs to be, but I have managed to improve it quite a bit. No longer will my enemy just fly off into nowhere... now at least he will focus on his goal destination and make his way in the right direction. Unfortunately, he'll kind of miss it and circle around it a ton of times until he finally accidentally gets close enough to be considered arrived, but it's closer. I think it'll be somewhat easy to fix this, I just need to tweak how often he's adjusting his bearings and correcting for misalignment.

I've also managed to make some improvements to the Input system I was using. The one I'd found was quite effective in handling Xbox controller and Keyboard inputs, but did not have any Mouse controls. I ended up adding those and it seems to work dandy now.

Most importantly however, I've put a great deal of time into organization and development of the modules and components that will control the game. This includes an Interface system which will now control the display of text info on the screen. I've also added a component-based Object system which will handle all the game objects that will populate the level. This includes the player ship(s), enemies, triggers and events, waypoints, sound effects, terrain, etc. They each inherit any number of component interfaces, such as Moveable, Physical, Audible, which identify how they interact with their surroundings. Ultimately, this will improve on the way the objects interact with each other because it will ensure that things that have no business effecting one another will be able to.

Finally, I've been working on adding some of the things that will add the zest to the game... weapons, armors, gear, an inventory system, money, etc. It's kind of ridiculous how much I've laid out in such little time. I hope to see some really cool results here shortly.

And Then...
I'll put a wee bit of time into the enemy patrol AI again tonight. I would like to see the enemy at least able to make it from point A to point B to point C smoothly before moving on. I'm relatively close to that now, so I anticipate finishing this up quickly tonight so that I can move on to more entertaining things, namely ...SHOOTING STUFF! As I mentioned, I have the architecture to manage the weapons and armor in place, I need simply integrate the controls so that weapons actually shoot. I also need to display the shooting somehow and generate bullets and then finally calculate the impact of the bullets and do damage. Lots to do, so little time. I'll keep me posted (being the only reader).

Thursday, April 2, 2009

Bespin Ahoy

I've been dreaming recently of where to take this little game of mine. The theme is actually kind of the hardest thing for me to settle on. There's infinite possibilities, really, limited only by my own imagination. Fortunately for me, I have a wild imagination. Unfortunately for me, I need to settle on one single idea and, as stated previously, I can be indecisive.

I've been thinking lately of graphical non-sense, for some reason. Like, how I will draw the moon in the sky and how I will light it? ...How I will draw clouds in the sky and allow the player to fly through them... perhaps hide in them, and how the light from the ship's guns will illuminate the clouds. How the backgrounds will show local detail when near the ground and also power lines going off into the distance, how that will grow into distant cities and lights and fields as you gain altitude. But ehh... all this stuff should be among the last things addressed - the art, the atmosphere, and the polish. Bleh, well I guess it's probably important in keeping me focused on the game and not too focused on the mundane aspects of it, so... Dream on!

Progress
Last night I came to a realization that I was over-complicating a few things. If the enemy needs to change heading and speed, then I should just let them do it, not worry about queuing and prioritizing and all that nonsense. The code will be simpler. The bookkeeping (See that? A word with 3 consecutive double-letters... crazy!) will be lessened. The enemy will behave much more player-like also. I put some work into streamlining this process. My enemy can now adjust angle and change speed at the same time as I'd wanted. As I left it however, the enemy does not re-adjust angle as needed... the enemy will set his desired angle, change speed, and as a result of acceleration the required angle-to-destination will change.

On The Docket
First: Allow the enemy to adjust his angle on the move. Also, lower his cruising speed, cause currently it's at 50% and he kinda books it.
Second: Make the enemy monitor his progress to his destination and then slow down and stop when he arrives.
Third: Make sure he'll do his thing in continuing to the following waypoints and back again as necessary. (think this should already work, just haven't been able to get him to make it to the first waypoint yet... hehe)

With these 3 things done, the enemy Patrol AI will be complete for now and I can begin working on Attack mode... need to work on guns and bullets and whatnot. Fun stuff!

Wednesday, April 1, 2009

Goal: Blog... Plan: Sign-In To Blogspot, Collect Thoughts, Type

Oy vey! You know, I thought AI coding would be a walk in the park. See the sights. Get some exercise. Feel good about life. Yep, not exactly. It's actually been a big headache so far. :P I'm not sure why either... usually when the problems and dilemmas arise when it comes to my game coding I get a little glisten in my eye and plot and scheme and it all turns out... as well as it could, I suppose. But this AI stuff ain't so easy.

I think these initial woes are probably mostly due to the overwhelming choices available in the AI field already (I don't tend to do well with choices, as I'm often one of those indecisive types). Also, I think I'm one to thrive in conceptualizing these sorts of things the way I want it. Sure, in such a field as AI that's been done to death since the 50's(?) it would almost certainly be reinventing the wheel, but I would ultimately hold a greater understanding of the result, and more importantly, it would truly be "my take" on it. So, I've been doing some scheming and here's a taste...

AI Notes
Goal (long term goal - e.g. kill enemies, work, score points)
Originally thought of a Goal Queue, listing more than one, but I don't foresee an enemy living long enough to require more than one...
PlanQueue (steps to accomplish goal - e.g. capture flag, return flag, defend flag, kill enemies)
Plan to accomplish goal is determined when the goal is set. May vary based on randomness or enemy smarts...
StrategyQueue (steps to accomplish plan - e.g. locate flag, pickup flag, attack, maneuver)
Small scale to-do list. Will vary based on randomness and enemy smarts...
ActionQueue (immediate actions or reactions)

Looping Logic
1. Gather Info / Build Awareness
2. Act (process plan/strategy queue if no threats present)
2. React (immediate reaction to threats found)

And an example of the queue-ing logic...
Goal: capture flag
PlanQueue: locate flag, pickup flag, return flag
StrategyQueue: locate flag
ActionQueue: locate flag
Awareness: flag found at enemy base
PlanQueue: pickup flag, return flag
StrategyQueue: go to flag, eliminate defenders, pickup flag
ActionQueue: go to flag
Awareness: 1 threat - long distance
ActionQueue: go to flag, determine threat level of Threat1
Awareness: 1 threat - no immediate threat
ActionQueue: go to flag
Awareness: reached flag
StrategyQueue: eliminate defenders, pickup flag
Awareness: 1 threat - short distance
ActionQueue: determine threat level of Threat2, go to flag
Awareness: 1 threat - engaging
ActionQueue: engage Threat2
etc.
etc.

Progress/To-Do
I managed to correct the enemy logic a bit. My enemy doesn't fly straight off the screen any more. Instead, he changes his angle and -then- flies off the screen. Oooooooooh! Well anyways, we'll see how it goes.

Monday, March 30, 2009

A Great Darkness Looming on the Horizon

There are stirrings about. Rumors of war... with... gray blobby things! *gasp* Yeah, I don't really know what I'm talking about either... I started working on the enemies for my game and my first enemy test sprite is... well.. a gray blobby UFO looking thing. It's scary, lemme tell you!

Progress
I was able to work on my game a wee bit this weekend. Only a few hours on one of the nights, but hey it's work, and progress was made! I mentioned the desire to complete my camera and control work so that I would have an enclosed playground to play around in. Well, my desires have come to fruition!
I was able to restrict the camera to within the map boundaries pretty easily. It took longer than it should have, because the landscape I was drawing to the screen was not positioned properly, and I took that as a flaw with the camera focusing, but I tracked it down before I spent too much time barking up the wrong tree.
I also managed to restrict the ship's movement to within the map boundaries. I'd originally messed with reversing the ship when it hit the boundary, but I found the resulting bounce-back somewhat undesirable. Ended up setting it up as if it were a wall. The ship will simply stop moving forward at the edges. Nice!
That stuff aside, I was finally able to start digging into the Enemy code... woo! I... actually made some substantial progress in a really short time. I've got a ship that appears on the screen and will try and patrol along predefined paths. More importantly, I've got some serious state and behavior management integrated already. The enemy will decide whether it should be Attacking, Guarding, Patrolling, Hiding, Fleeing, etc. Deeper still, he will decide when he's Patrolling (the only behavior I've addressed so far - want to get it working before proceeding), how he will patrol. Where will he go? How fast will he get there? What will he do when he arrives at each waypoint? Will he turn back when he reaches the end, or circle around back to the beginning? I've made all these variables... well, variables, so that I can make any number of enemies that might patrol differently quite easily.

The Rigamorole
I have several issues facing me immediately and they actually present quite a challenge. For instance, I set up a Queue of actions I want my ship to take... like correct it's angle, change it's speed, etc. The problem I see is, what if I want to change it's angle and accelerate at the same time? A single depth queue could make this quite difficult. Also, if I were to queue up multiple things at once, do I perform the entirety of the queue at once, or do one action, then the next when the first completes? I'll want the enemy to be capable of moving and firing at the same time, for example, so I need to figure out a way to achieve this. How will I prioritize some things over others? Hrm. Yeah, I don't know either. Perhaps some research on AI would shed some light on things. I'll see what I can find. Anyways... immediate goal: get my enemy ship to patrol properly... right now he doesn't change angle and slowly accelerates to the right off the screen forever. Smart guy...