Tuesday, July 21, 2009

Blog and website combined: www.mhgames.org

Hi, to all my readers (yeah all the two of you! ;) ):
I have created a new website, that is a combination of my old game site and this blog. No need to worry, the blogging will continue as usual, just head over to the brand new site at http://www.mhgames.org and browse away!

With this post I'm freezing this blog, no more updates here. I will let it stay online for archival purposes, although all this content IS already imported to my new blog so nothing is lost. :)

Thank you for your interest, hoping to see you at mhgames.org!

-- Mika

Sunday, July 5, 2009

Geez, it's been a while...

Time for an update, I reckon.

Although PolyAnim is generally on hold due to the game project, I made a few optimizations (reducing garbage generation mostly, still quite high though) to it. As for the game, I'm still working on the engine side -- BUT -- I've written down some things on the game plot and other design! I have a vision of the game beginning, but the actual plot still needs to be thought up. Sooo yes, I don't have much at all, but it's a start. :D Luckily I don't have too much pressures on the story side, as even if it ends up sucking donkey balls (excuse my language), it's still infinitely better than the "stories" of my previous games combined! ;)

Meanwhile, in the programming land...
It's been so long since my last update, I've worked on so many things I don't even remember them all. Instead of trying to remember the details, I'll just list the things I do remember:
  • First of all, I started using revision control for the source code (+ related resources). Instead of using the familiar Subversion, I decided to try something new and thus chose Git. All in all, this helps me keeping track of the things I do and also serves as a backup in case my computer decides to blow up. Git is nice since you can use it locally, on any directory without a server.
  • VBO (Vertex Buffer Object) support. This means storing geometry to the GPU and rendering it in one batch. Basically it means better performance. Using VBOs I could optimize the text rendering by buffering the rendered glyphs into a batch, up until the buffer fills up (or the texture changes). The buffered glyphs are rendered in one go, and the process starts again.
  • Particle systems! I started doing a "particle engine" a while back, got it done except for the different emitters. I still need to finish this up: complete the basic point emitter, add more emitters and add the ability to load particle systems from resources (perhaps a YAML or XML file). VBOs are used to render the systems, when supported by the GPU.
  • Lighting system improvements. Lights can now have different effects on them, like flickering, fading and pulsating. The effects are defined in a YAML file of properties.
  • Player character designs. I'm not sure if this guy ends up being the final character, but might be. I did a quick idle animation for him (need to adjust that a bit, though), I should add a walk cycle next as it's quite boring to watch now. (The previous animation, test from PolyAnim, did walk!)
  • And now for something completely different: Water effects. Yes. This is mostly eye candy (as Box2D doesn't support buoyancy yet, I think the water is only going to be used for restricting player movements as in the player can't swim..) so it made no sense to do it at this phase of development. But I did it anyway, I'm childish like that.. :P The water reflects the scenery above (provided the GPU supports Render-to-texture) and I even wrote a fragment shader to make it all wavy and twirling..
I have noticed a problem during the development of this game, which was not apparent on my previous game projects (since they were much shorter): I have this annoying tendency to start working on different (sub)projects even when the previous stuff is still not finished. That means I have heaps of unfinished subsystems in this engine, like the particles, scripting, triggers, etc. And I'm already thinking of doing the sprite system and other things as well! I mean, what the hell, it should be bloody obvious I should concentrate on the unfinished things and finish them.. :P Argh, hopefully I can sort this mess out. Speaking of which, I guess I should start coding the particle system to an usable state.

And of course, to all aspiring game developers: design the game first, damnit! Figure out the plot, setting, characters and whatnot BEFORE getting sucked in the bottomless fathoms of Teh Engine(tm)! Yes, I really should take my own advice some day! :P

Monday, April 27, 2009

More progress: Quad trees

Today's subject: quad trees. Here is a nice little tutorial on the subject.

Until now I was using a naive method of rendering the level shapes (polygons and circles): I looped through them all, did a bounding box check* to see if they're visible in camera, and rendered if they were. This works fine for small levels (and indeed for the current test level, although I keep adding more and more stuff to it -- nevertheless it's still quite modest in size), but for larger levels it can become a problem, especially on slower machines.

So I decided to add quad trees to speed up the level rendering process. The level shapes are stored in three different quad trees (one for collidables, one for background and one for foreground shapes). The trees are queried for visible objects, which then get rendered. Works nice and smooth, and the performance goes through the roof, right? Well... not quite.

Since the level shapes can have various opacities, it is important to render them exactly in the order that is specified during level creation (in the Inkscape SVG file). In the triangulation & convex decomposition process the original shapes get split up. It was not a problem during the naive approach -- the shape parts were in a list and the original order was preserved. Quad tree on the other hand doesn't necessarily preserve that order, to my great disappointment. It makes sense of course, I just hadn't thought about it until I saw the effect: a few of the level shapes were rendered out of order.

At first I tried to come up with a way to partition the quad tree so that the order would stay correct, but that didn't work too well. In the end I ended up just sorting the queried objects before rendering. That works perfectly, but introduces a new speed hit; the sort. So in all, the supposedly great speed increases of the mighty quad tree turned out to be only a modest gain, since I now need to sort the visible pieces.. Still, I'm confident that the quad trees were worth it, as the levels keep getting bigger and more complex it will surely show more greater effect. :) And at least I found that enormous bug in the bounding box culling! ;)

Check out a few debug screens below, quad trees are the white lines.

*) I actually found one of the most stupid bugs I've ever done in the bounding box check code. It was actually checking bounds from the world origin (0,0) to the object lower right corner, instead of from the object upper left to lower right! That means that the bounding boxes got very big and only the objects to right and down from the camera view were culled properly.. Ouch.



Sunday, March 29, 2009

Engine progressing slowly but not-so-steadily..

Once again, I've been improving the platformer engine. I have done a lot of internal restructuring which isn't directly visible on the screen. Remember, this project started as a quick hack testing JBox2D, so the oldest parts of the code were a total mess. Cleaning it up, I implemented modules, that the engine keeps processing. These modules (e.g. GameModule, MenuModule, OptionsMenuModule) are basically separate states and can be ran separately of each other. They also support transitions, so a title screen could fade into the main menu, which could then roll off the screen presenting the actual game. Currently I have an initial loading screen that fades into the game. Yes, all this doesn't sound very exciting (and in reality it isn't), but it makes the code much more cleaner and modular. Hopefully, one my biggest pet peeves -- which is writing the menus after the game is complete -- will be a more pleasant experience with these module supports in place. :) I still have some old physics related code there which needs some refactoring love, so there's still work to be done..

I also did the different rendering path thing I was talking about earlier. The best rendering path allows for some neat shader effects, I did initial tests with a distortion shader -- it was nice but didn't work with the bloom effect, something I hadn't realised before. I guess I will need to implement somekind of a post processing subsystem, that does the bloom among other effects. Oh well. :)

Another thing I added is an ingame profiler. While extremely simple, it still presents some very useful data so I can see what part of the game takes most time at runtime. So far the slowest thing is the text rendering. Luckily that won't be a problem, since I don't plan having much text on screen in the game (apart from dialogue, but that can be prerendered into a texture). In the current demo I draw the yellow text with a nice shadowy border around it -- that is a very brute force approach which just draws the same string a bunch of times. That's very slow. Also the text rendering could probably be optimized more, should the need arise.

I've been also improving the controller support (yes, the game will support game pads! That's the first time in my [released] games -- better late than never, right! ;) ). The basic support was actually added months ago, I just forgot to mention about it earlier. It's still pretty much unusable, since the buttons cannot be assigned: it just uses the first two buttons on the game pad. And that varies per model, a lot. On mine they're positioned logigally, but on another pad they were almost unusable.. So the game needs a controller configuration screen, where the player can assign the actions to the preferred controller buttons. But that's thinking way too much ahead, I need the game first! :P

One more thing: I made a simple test release of the engine, so that I could collect some data on how it works on different machines. (I mainly test it on two computers, which isn't that much.) Head over to the JavaGaming.org forums and take it for a spin! Hopefully somebody confirms it works on Mac OS X as well.. :) [Update: Yes it does!] By the way, I will probably take the thing down in some time, since it's still in very early stages and doesn't have any gameplay in it anyways..

That is all this time, stay tuned for more! EDIT: I just realised I had used this very same line to end the previous posting.. Am I really this unoriginal!? Apparently, yes. Yes I am.

Tuesday, February 10, 2009

Platformer progress

After a long break I've started working on the platformer engine again. I've added a material system, where every level shape (i.e. polygon) has a material assigned to them, which defines the texture and physical properties (friction, restitution and density) for the shape. Later on this could be used to trigger different sounds or other effects based on where the player walks, for example.

I improved the lighting system to support rotating lights and finally enabled them to be placed to the level in Inkscape (the lights were previously completely randomly generated). To test these new features, I abandoned the ugly mess of a test map I had been using from the start, and built my first "real" level. It's not too detailed yet (and yes, ugly in some points too!) but at least it's better than some random polygons. I do plan to expand it to test new features as they get implemented. Check out these screenshots to see the brand new level in action. :) Disclaimer: All the textures etc. and even the whole style are temporary and not representative of the final game (if I manage to complete it some day), purely because I have not decided on the final style yet! I may opt for more stylished visuals, as in not using "realistic" (photograph based) textures, contrary to what you see in these images. But as I said, I'm not sure yet.

Speaking of new features, I added support for "floor shapes" - shapes that act as a floor but not as a ceiling. That means you can stand on them but jump through them only from below. You can also drop down when needed. These things are so common in platformers, so I had to have them in. Unfortunately I had to restrict them to be straight horizontal lines - "floor lines" like I call them in the code - due to technical difficulties with the Box2D physics. At first I tried doing this with Box2D sensors/contact listener but it seemed like a bad hack and would probably have not worked correctly in some cases, so I deemed it too much trouble and went for a simpler approach. My biggest gripe with Box2D is actually the contact listener, it's somewhat hard to use it nicely..

One of the things I'll start coding next is sprites, which will be used in several places: as normal level decoration, level decals, in the background and so forth. Currently everything you see is crafted from polygons, which is wasteful on the resources. In the current test level, at least the mailbox, arrow sign and mushrooms should be sprites.

That is all this time (got to run to the school soon.. :/), stay tuned for more! ;)

Monday, January 26, 2009

On Fallout..

Last week I finished Fallout 3. I somewhat rushed it through, as the urge to start playing Fallout 2 had grown too strong! :P I probably continue playing FO3 from an earlier save later, since I had heaps of places I didn't get to visit and a good deal of unfinished quests as well.

So what do I think of the game? Well.. It's a great game - much better than Oblivion, for example - looks great and sounds great. I enjoyed my time on the wastes a great deal. But... how could I put this... It's not Fallout! :/ While there are plenty of things done right (the VATS system works quite nicely!), it's still missing much of the good old Fallouty spirit.. The biggest problem is the dialogue: it's just not that good, especially when compared to FO/FO2. NPCs feel like answering or quest machines. Where's the humour? Not much of it left. The ending was not very good either, although not as bad as some people claim it to be.

Nevertheless, as I said, I enjoyed the game a lot, and will be playing it again. :) Perhaps they should've called it Fallout: Something something something, though. I had a few problems with the game: three freezes (two of them while approaching Evergreen Mills) where I must restart PS3, one crash and several little (graphical / physics) bugs. Not too bad, I guess. Lots of PS3 players have complained about worse problems.

And after completing FO3, I've been playing FO2 again, after many years. As I mentioned in my last post, I never actually finished the game and have held FO1 as the better game. Let's see if the order changes after I finish the part two. It's very hard though (at least in the beginning), much harder than I remembered. I think I've hit a bug though (I'm using Killaps unofficial patch 1.02.25 - highly recommended, I've yet to try the Restoration Project), skip the following paragraph to avoid FO2 spoilers.

*SPOILERS* I cannot seem to be able to give Bishops holotape and the Raider account book to Lynette in Vault City. I wiped out Bishops in New Reno, found the holotape in the safe. On my way to Vault City, I cleaned out the Raiders cave. At Vault City, I can tell several people I've neutralized the raider threat, and they say I should tell the First Citizen, but I cannot give the account book to Lynette. Nor the holotape. I tried before doing the Gecko power plant quests and after - doesn't work. Oh well, I guess I cannot complete those quests then. *END SPOILERS*

Now I just need to plug GOG.com, the Good Old Games! The service is excellent, so far I've bought FO1, FO2 and Gothic. The games come prepatched and DRM free, it's great. :) Good stuff, highly recommended.

Friday, January 2, 2009

Holidays and gaming

First post of 2009, yay. I've been taking a break from, well, almost everything: school, work, programming (yes, even that!) and instead spent time with family, playing games and being lazy in general. Isn't that just what holidays are about? :)

I have played lot of games lately on the PS3, mostly Little Big Planet and in these last few days Fallout 3. Little Big Planet is really fun, especially when played together with others (in my case that means my fiancée Annemari <3). style="font-style: italic;">Little Dead Space level was brilliant.

As for Fallout 3 (got it for Christmas), I'm very enthusiastic about it so far. * Feels a lot like Oblivion in places, but that doesn't bother me since I like Oblivion. My current Oblivion save has almost 60 hours put into it, and the game isn't nearly finished (I'm currently on the Shivering Isles expansion). The main quest is a bit dull, I don't like cleaning the Oblivion gates (hence Shivering Isles).. Fallout 3 on the other hand seems much better and more interesting. Maybe that's because there are hundreds of games in the generic fantasy world but only a handful (I'm only aware of Wasteland and Fallout 1 & 2) in a post-nuclear environment. This time Bethesda even hired more than three voice actors, wow! The game looks and sounds great, obviously. I guess I'll comment it more after I've finished the game.

After I'm done with Fallout 3 (not too soon, I reckon), there's a lot of unfinished stuff to play: GTA IV, Oblivion, Lego Batman.. :) In fact, I might even start Fallout 2 again, as I have never actually finished it(!). The original Fallout I've finished with at least three or four characters. Good times.

*) Yes, I'm aware the PS3 version is the worst of the bunch. However, it has trophies now and I haven't had any problems so far, apart from some minor bugs like a severed molerat head that just couldn't stop rolling around. The lack of anti-aliasing is a bit distracting, but nevertheless I can recommend the PS3 version... unless you got other options. I didn't (my PC is a bit too old).