Category Archives: Uncategorized

Tearing it down

I’ve had to break almost everything in my game. So much so that it’s easier to list things that I didn’t break. Why did everything break? Because I have deleted my entire Entity class hierarchy. No more Asteroid class, SolarStation class, LaserMiner class, etc. All gone, and good riddance!

Instead, I have been converting piece after piece into data-driven components with systems that process lists of these components. There is a great 5-part blog series on this topic over at T-Machine. I’ll describe what I’ve done once I manage to get a little more working. So far, I only have a single asteroid that consists of nothing more than a few components. It may not sound like a lot, but it is a great start to a data-driven game.

Asteroid Outpost Update 2012-07-13

Life has been rather busy recently. Between the Calgary Stampede, Close Quarters, a flat tire, and making invisible improvement after invisible improvement to the back-end, it has been a little tricky to find both time and motivation on the same day. I did have a few spurts of time + motivation, and have been moving ever so slowly toward an ES design (Entity-System). Since I didn’t start with one, or know about their existence when I started, the conversion process is a little extensive, and very invisible. When I’m done, I will have a scripting language in place for all of my entity-specific code, components that are 100% data, and systems that will work directly with the components. This should allow for two major things: rapid development of new entities, and modablility. Modability being a side-effect, I really just want the rapid development. Oh the dream.

Asteroid Outpost Update 2012-06-12

Over the weekend, I integrated Awesomium into Asteroid Outpost, and it looks pretty sweet, but not only that, it’s easy to make changes to. Instead of posting stale screenshots, how about you check out the screens for yourself! They’re just html after all. Here’s a link to my Awesomium Screens for AO. They will only work properly in Firefox, Chrome, and probably Safari. IE will partially work, but all of the cool CSS3 will be stunted and cause the page to look lame. Also note that the background image in this sample is only 1920×1080, so if your screen is gigantic (like mine), please reduce the size of your browser window for your viewing pleasure. Some things you may not think of trying:

  • Use the arrow keys, and press enter to navigate the menus
  • Press ESC once in the game* to bring up the in-game menu, press again to dismiss
  • None of the text is selectable. This is really annoying for websites, don’t ever do this, but this isn’t a website, and selecting text in a game is weird

If you hadn’t noticed, the multiplayer menu isn’t completely working yet. That will come. I want to get a few more features working first, like tooltips and maybe a console? I kinda want to make an html console, especially after looking at Wolfire’s blog post about doing awesome CSS3 transitions for text entry. Like, is that sexy or what? In case you were wondering, reading Wolfire’s blog is what inspired me to use Awesomium.

Also, MindWorX and I have created an AwesomiumXNA component that you can easily add to your own XNA project. Here’s the project on Bitbucket.

  • not really in the game

New Screens on the Way

Diablo 3 has been consuming me! Good news though, I wasn’t playing D3 the whole time, I did manage to scrape together a few minutes here and there to work on some new web-based screens for Asteroid Outpost. I should have something to show soon, and be prepared for some major differences. The new interface should be way easier for people (including you!) to edit, and will allow me to make some much-needed UI changes on a whim: tool tips, icons, progress bars everywhere, a console, mutiplayer chat, some proper controls for the server settings, need I go on? The first version I’m planning won’t be pretty, and will only replicate most of the functionality for the singleplayer portion of the game; multiplayer menus, the radar, and “pretty” will have to come later.

You might be thinking: “Won’t a web UI feel like the web”? Thanks for asking, and nope! I’ve been trying hard to make it feel like a native UI, and it’s surprisingly easy. Add some JavaScript keyboard support, a dash of CSS3, a few special keywords, and you’d be hard-pressed to tell it was html.

Awesomium!

I have recently discovered Awesomium, a “windowless web-browser framework”. But guess what? That’s not all it can do. It can also be used for HTML UIs. Two games that I can name use it right now: EVE Online and Overgrowth (lots of fun btw, but I won’t get into that). In the back of my mind, I’ve always wanted to go back, fix up my UI system, add new features, and correct all the wrongs (of which there are a lot of). UIs are a pain, a massive pain. When you get it right, it’s fun, but I’m so anal that I need to (try to) get every detail right, and make it work as similarly to the Windows controls as possible (at least for the features I implement). Don’t believe me? See this diagram for selection logic in a table that I made several years ago. Mouse scroll wheels and key repeats are some other areas that people get wrong far too often. I should get back to the point before this rant goes on too long.

So yeah, I’m sick of writing UI code and I think it’s time I let go of the reins. Awesomium might be the replacement I’ve been (idly) looking for. In about 30-60 minutes, I downloaded and installed the SDK, looked at some samples, and successfully displayed Google’s homepage inside my XNA window. Pretty straight forward if you ask me. The only tricky part was converting Awesomium’s RenderBuffer to XNA’s Texture2D. I did it like this:

if (webView.IsDirty || webUITexture == null)
{
    webUITexture = new Texture2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color);
    webView.FlushAlpha = false;
    webView.IsTransparent = true;
    RenderBuffer renderBuffer = webView.Render();
    byte[] imageBytes = new byte[renderBuffer.Rowspan * renderBuffer.Height];
    Marshal.Copy(renderBuffer.Buffer, imageBytes, 0, imageBytes.Length);
    webUITexture.SetData(imageBytes);
}
spriteBatch.Draw(webUITexture, new Vector2(0, 0), Color.White);

Probably not the most efficient way to do it, but it does the trick for now. We’ll see if I have any performance issues when I add this to Asteroid Outpost. Once I got Awesomium drawing, I basically had a working web-browser inside XNA. To my surprise, even YouTube worked, with sound! Pretty sweet. Did I mention that you have to add some bypasses for the mouse? The bypasses for the mouse are easy though. The keyboard? Not so much. In my evening of programming, I didn’t spent enough time on the keyboard to get it working. Here’s what I did get though:

Awesomuim in XNA

Everything except the title bar, and the cornflour blue is being drawn by Awesomium, and if you click the “Link!”, it loads my blog inside the same XNA window (How’d you think I found out it plays Flash?). It’s obviously very powerful. I haven’t played with any interaction between Awesomium and XNA yet, but that’s next on the list, right after I fix the colours. The Blue and Red channels are swapped. I need to play with the SurfaceFormat in my call to Texture2D because Awesomium uses BGRA, while “Color” must use RGBA. I have uploaded the source code for this to Bitbucket if anyone wants to check it out.

Oh, and I added a very quick automatic refresh when the source HTML file has been modified. Finding my CSS errors was a lot easier when I could just look over and see what was going on with every change. Well… it’s basically a web browser, why am I surprised at how easy it is?

Asteroid Outpost alpha4 Release

For those who want to try out Asteroid Outpost, I have uploaded a new Asteroid Outpost binary to Bitbucket and SourceForge. Some of the changes are:

  • Icy Planet in the background and nicer looking stars
  • Health bars with floating damage indicators
  • Rewritten power grid with lots of bug fixes (Why the rewrite? The old one was built right into the entities, this one is its own separate object and much easier to handle because of it)
  • Better networking code and significantly fewer network glitches
  • Starting a component-based system
  • Lots of bug fixes

Now that I’m using Mercurial, I can’t be lazy and just use SVN’s revision number to tag the release, so I’m starting the count at 4 because it looks like this is my 4th public release since… wow… since September 2010. Dare I see what AO looked like back then? Yeah… let’s do it. LOL, wow! Awesome. That makes me feel awesome inside.

Asteroid Outpost Update 2012-05-04

I have just finished fixing up how a network game is initialized, at least for now. First the scenario is initialized, this creates the asteroids, force(s), local controller for the server, power grid(s), and an AI controller (if applicable). Next, the network class gets a chance to do its thing. For each client, it serializes and sends the game state that was created in the scenario, then asks the client to create its own controller and start the game. Sounds easy right? Well, it is now.

A bug was also introduced, or at least noticed during this latest round of changes. It’s a small graphical glitch, I think. On the client, my structures aren’t completing construction properly. So far, this is only making the power lines between two power nodes show up in the “constructing” colour:

2012-05-04ConstructionBug

Power Grid Demonstration

I have compiled a short video demo of how the power grid lights up the shortest path from consumer to producer. Check it out (720p and up is recommended):

Also visible in the demo is my ice planet, beacon (green thing above the planet), and some stuff related to the tutorial scenario I am working on.

Sprite Thoughts and Life

I was playing an early alpha of a friend’s strategy game and noticed that the animation of the character’s feet wasn’t in sync with the ground below it. This got me thinking that I could add a feature into my sprite maker where you could preview what your character would look like at various animation speeds in relation to ground speeds so that you could more easily sync the two up. I still need to add the registration points to the editor too, my lasers are going to need those really soon.

Somewhere down the line, I would like little rotating turrets on my spaceships and battle-stars. With my current isometric point of view and 2D sprites, this could prove challenging. Just thinking out loud: I would need to use an orthographic projection of my models (but maybe not), then draw the sprites in a few parts to handle special cases like where a turret is partially obstructed by a tall part of the structure it’s attached to. If I handle cases where a turret can be obstructed by the structure it’s attached to, I’d want to handle that (somehow) in the sprite maker because the purpose of the sprite maker is to abstract these sorts of details from the programmer and let the artist handle all of this artsy stuff.

Not that I used to get a lot of search referrals, but I have not had a single search referral since I upgraded my website. I’m pretty sure I broke something. That ought to teach me to upgrade my website. Anyone had this problem, or know how to fix it? All of the old URLs no longer work, and you’ll get a friendly 404 if you try. I’m certain that has something to do with it.

Life has been keeping me rather busy recently, so I haven’t had time to develop AO any further :(. I’m hoping to get a few hours in this week though, see if I can make a quick video of the power pulsing and finish up with the network cleanup. The networking has a few complexities that need some thought, like: Will updating a ship’s location, velocity, and target, only when the target changes be sufficient enough to make a smooth client-side simulation? or will more updates be required? My instinct tells me that this should work just fine, as long as the game knows when this target change occurred and how to bring the ship into the present (keeping in mind that all network packets come from the past). There are some other organizational issues around how to send the initial state of the game to the client and how scenarios tie in to all of this, but I’ll elaborate on that in an other post.