Sunday, July 29, 2012

CDN 2012 Game "Fireflies" Postmortem

Fireflies Game Home Screen

This year the whole Bearhanded team decided to participate in the Christian Developers Network Speedgame.  We created an online multiplayer game called Fireflies.  The theme this year was "testimony" and we decided we wanted to do a multiplayer game with HTML5 and NodeJS.  What came out of our brainstorming was a simple puzzle game where players control various types of game pieces and use them to get to the exit in each level.  To accommodate the testimony aspect of the competition, we chose to show how each person's testimony is influenced by many people and so we created a sort of spiritual family tree in which each level starts out dark and after completing each level it lights up and the next level is unlocked.  The idea being that God uses many people in our lives and in their lives to reach us with the gospel.  When the whole tree is lit up, then the game is completed and the #parteh begins!


Fireflies Game Level 1
Level 1 is very straight forward no?

There are 5 levels, starting with simple puzzles and ending in some rather difficult ones.  The final level is very difficult to beat by yourself, and even with three people it can take some time to finish.

Fireflies Game Level 2
Every game needs a jumping puzzle! #lies

Design

We took our design cues from games like Lemmings,  Limbo, Botanicula and whatever was tossing around in our subconscious!  Chris was the primary designer and Aaron took his characters and animated them using After Effects.  Nate then took the animations and put them in the game.

Development

Fireflies was built with the following technologies & libraries
  • NodeJS - server game logic
  • NowJS - server and client networking
  • HTML5 - client audio and canvas support
  • CSS3 - text glow effects and drop shadows
  • Box2d - client physics
  • Cocos2d-javascript - canvas drawing
  • jQuery - various UI elements
I did all of the Javascript for the server and client using Aptana as my editor.  This editor is free and good looking and the code completion is pretty decent.  It's basically another flavor of Eclipse.
I love using dark text editor themes - if only it darkened the frame too #sigh
Chris used Tiled to build our levels and Nate used Zwoptex to make our sprite sheets for our animations.  Both are free and support Cocos2d.
Simple, but it works and it's free!

Thoughts and ramblings

For anyone interested in using any of these technologies you should be aware of several things I discovered:
- Cocos2d-javascript is still very alpha, with lots of unimplemented features, many bugs or things that don't work in every browser, few working up-to-date examples and not very optimized.  All that being said, it does work for simple things and it performed fairly well for our little game.   To integrate box2d physics with cocos2d I had to modify the level import code to support reading polygon objects.  Then in my client code I used the polygons to create box2d static shapes.

- NodeJS is really hot these days and can do some amazing things.  No complaints here except that it uses Javascript.  All the wonderful things you are used to with object oriented programming are imitated and asynchronous behaviors abound.

- NowJS allows you to easily synchronize variables between server and client and do remote procedure calls, however I quickly discovered that due to the asynchronous nature of  NodeJS, using variable synchronizing would give random bad values and I ended up having to use remote procedure calls for everything.  The groups feature is how we contain players in levels and it is super easy to do and useful and awesome.

- Box2d is made for realistic physics, not platformers.  I really had to punch it in the face to get it under any semblance of control and the player input still feels awkward and annoying to me.  Physics engines sound like an obvious choice when you're making a puzzle game, but when it comes to platformers you want a certain un-realistic feel for player input 9 times out of 10.  So to bring box2d to its knees I had to
  • Use a ball for the players physics shape so it wouldn't get stuck and friction wouldn't be such an issue.  
  • When the player is on the ground and not providing input, set the friction really high and use damping to slow the player down fast.  When they move ease up on the friction. 
  • When in the air, turn off friction and use a different damping or they'll get stuck on vertical walls.  
  • Use impulses and not forces to get the player moving.  
  • Turn off restitution or just use a tiny bit or you'll bounce all crazy.  
  • Make sure your polygon world objects are created with the vertices in counterclockwise fashion or your player will fall through them.
  • Make sure the player's foot sensor isn't too wide or they'll be able to wall jump - unless you want this behavior - super meat boy anyone?
That's it for now - you can play the game at http://fireflies.bearhanded.com and the source code is available for download via the christiandevs.com website here. 

In other news I will post about the latest OGE/planet updates soon and I co-authored a book on OGRE. 

Monday, March 26, 2012

Spacescape for OSX, OGE gui and 2011 Games

Let's hit the "games I played in 2011" first - btw I'm stealing this idea from nathan @ ntdb.org. I think every game developer should be required to do a post on games they played once a year! Brilliant.


Natural Selection 2 - naturalselection2.com

This has been my go-to game of late because it just keeps getting better and better with each new Beta release! If you haven't heard of this game, it is a remake of the original which pits alien forces against marines in a FPS  & Strategy Game mash-up.  Each team has a commander who plays the game from a top down perspective and deals with building, upgrading and collecting resources for the team.  The commander on the marine side is also charged with directing, healing and keeping bullets available for his teammates.  Each side accumulates resources through the game by building structures on resource nodes throughout the map.  Resources can be spent on upgrades, or in the aliens case, for evolving into more sinister life forms.

The only minor downside of this game is that it isn't OSX compatible yet so a bunch of my friends can't play it because they drink the Koolaid!



The Elder Scrolls V: Skyrim - elderscrolls.com/skyrim

This is obvious no? Great graphics, huge expanse with variable gameplay, and I would  be playing this a lot more if I weren't playing natural selection all the time.  I really like how this game looks and the openness of the gameplay, my only gripe is that every dungeon seems to be the same type of experience: kill bad guys, kill boss, come out alive.



Left 4 Dead 2 - l4d.com

I started playing this with friends at work and had a blast!  I did enjoy mindlessly killing zombies while drinking a beer after a day of twisting my brain this way and that.  Great way to unwind and I keep it in my back pocket in case I don't feel like playing TF2.



Minecraft - minecraft.net

There are only two games that my wife and I both get and this is one of them.  The creativity in this is addictive and it is the only game I have like this.  I want to make a game as creative as this one some day - and I mean one that allows players to create and really use their imagination.  Love. It.  



Portal 2 - thinkwithportals.com

Played this in single mode and then co-op mode and enjoyed every minute.  I simply couldn't stop playing it and it was so refreshing to have an action game with humor in it.  I think Valve has the corner on the market in pulling together all the gameplay details and story line together, plus I just love puzzle games.  Co-op mode was icing on the cake and I wish there were more longer campaigns.



Civilization V - civilization5.com

Bought this on sale and the graphics look great, but I don't have enough time to play it.  My wife loves Civilization but her computer can't run this version as well, so she is sticking with IV for now.  The gameplay changes don't bother me, and I actually kind of like them.




Team Fortress 2  - tf2.com

Always a classic.  I play this mostly to unwind in a gore-free environment.  Going free-to-play was a good move for Valve - I bet most of their players purchased the game a decade ago anyways.



Honorable mentions...

Lord of the Rings Online

This was the only MMO that I tried and I did enjoy it but you really have to spend a lot of time to do stuff in these types of games.  The graphics are decent for an MMO and there is certainly a big community, especially after they went free-to-play, but when the Star Wars MMO came out, a lot of people went on hiatus to try that.  Most of my guild friends did.  I quit playing in 2011 and will probably not return until I have significantly more free time.

Tiny Wings 

My favorite casual game.  Simple, carefree and fun.

Sam & Max

I play through these with my wife on the TV sometimes when we're bored, the internet is down and the like.  These are really fun little games and are fun to play with another person sitting beside you.

Sonic 2 for iOS 

A classic from when I was a kid and played it on a Sega hand held.  I cheat now to get to the higher levels that I couldn't get to when I was younger.

Counter-Strike: Source 

I only downloaded this game and played it to see what was going on with the most popular online shooter game.  More of the same.  Graphics refresh was nice and I like the new maps, but I never really got into the original and stopped playing this one after a little while too.

X3

These games are like references for me and full of ideas I want to have at hand in space games that I make.  The story lines are teerrrrrriiibbbllleee and the voice acting is equally bad, but the space graphics are pretty amazing.  Eve Online also has some great space graphics, but I couldn't stand the gameplay and the MMO aspect was not enough to get me to pay a monthly subscription fee.

So that's it for the games I played - I may have played other games, but those are the ones I remember.

OGE GUI Experiments


In the world of game development I've been doing more work with GUI's in OGE. I added a console and a simple menu system to explore the ins and outs of the MyGUI library.  I suspect it is causing some framerate issues, but I haven't been able to track those down yet.  I'll probably post a video of the GUI additions later.  I've also spent time trying to better implement input and physics for moving.  In fact most of the GUI system I have created so far has been to allow me to tweak input parameters to get it to feel right.  It still doesn't.


Spacescape on OSX

I actually managed to get a version of Spacescape to compile on OSX and run, but it has some major issues with masks and the whole build process was hell.  Since I've been doing a lot of XCode programming with work projects I think I'm going to dispense with the QT framework and trying making a native Cocoa Spacescape app for OSX and a native Win app for Windows - sorry Linux!

I have learned, through opensourcing the code for Spacescape and trying the donation thing, that besides it being a nice little feather in your hat, the only thing you get out of open sourcing and giving away a small project like Spacescape is a bunch of thank yous and a ton of support requests.  I intend to do a full write up with my thoughts on the whole business, but in short, I'm ready to attempt a different model.  I think the next iteration of Spacescape will be closed source and I'll use a pay-what-you want model with some minimum to cover fees, support and future development.

Friday, August 26, 2011

CDN SpeedGame Postmortem!

Would you believe it - I don't even have enough free time to make a little speedgame?!? Maybe I was over ambitious but I'll get to that.

So my entry into the Christian Developer Network's 2011 SpeedGame was going to be a Robot-Unicorn type game but with a cat. We each had to pick a verse as a theme for our game and I chose Proverbs 15:24 - the lolcat Bible version.

Proverbs 15:24 - Smrt kittehs go up, not down to da basement.

The basic gist of the verse is wise people are on a path leading upward and they turn away from death/hell beneath. I made a game about a cat that falls asleep during a thunderstorm and dreams that it is running away from the storm, jumping from platform to platform as the storm gets closer and closer. Really simple concept - I mean you just have two controls, jump and fire. Jump to stay on the platforms and fire to deal with obstacles in your way. The obstacles would slow you down and if your cat doesn't keep ahead of the storm approaching from the left side of the screen it gets soaked and you lose! This post is about the game dev process and the hiccups I had along the way that I'll share my solutions for and hopefully they will be helpful for other Ogre game devs.

But first - a simple rundown of the tools and libraries I used for the game:

- Ogre 3D graphics engine (duh)
- Box2D physics
- OpenAL audio
- Gorilla GUI
- OIS for input

- Blender 3D for models
- various free model and sound websites for the developer/test content

OK, so in the roughly 20 days we were given to do actual dev work on the project I decided to build a cross platform twitch based game. That was the first hiccup. I spent roughly 2/3 days just getting basic Ogre working on Windows, OSX and iOS. What I did was download the SDK for Windows, OSX and iOS and then I set up this folder structure to house it all.

- design <-- all my design files
- GameiOS <-- iOS specific XCode project
- GameOSX <-- OSX specific XCode project
- GameWin <-- Visual Studio 2010 project
- lib <-- Box2D and OpenAL libs/source
- media <-- all models, sounds, graphics etc.
- src <-- all the shared source code

Cross Platform Luv

Windows was cake to setup for just about all the libraries. iOS was a bit more difficult because you have to compile the libraries for the right architecture to run on the device and different ones to run in the simulator. OSX had issues with just working at all. I tried to use the XCode 4 templates to create a new project but even when I got it to compile it would crash on startup. Eventually I found that if I moved the log manager initialization to a line after Ogre::Root was initialized then the crash went away and I could proceed. So all that debugging on OSX and the extra iOS configuring took me a couple days of free time.

Oh, and OSX fullscreen mode just doesn't seem to work -- which was annoying because I had to restart my computer to regain control.

After getting the demo app working cross platform I put it all in a GIT repo (always a good idea to backup your code).

Physics Physics Physics

The next step was actually implementing the game, so I created prefab boxes in Ogre for the player model, the platforms, the bonuses and walls - everything and tried to hook up the Box2D physics. It wasn't that hard to create a Box2D hull for all the objects because they were all square initially - however I ran into major issues getting the Box2D step() function to be framerate independant. In fact, to this day the physics speeds are different on each platform even when I confine the framerate to roughly 60 fps, and this annoys me to no end! I even got a helpful hint from azrialelf on the Ogre forums that he just created a framelistener and told Box2D to step with the evt.timeSinceLastFrame as the time delta. This does work OK, but it still doesn't behave the same on all platforms and still seems to be affected by framerate somewhat.

One other big gotcha with physics on iOS and OSX is that the demo app run the main loop with a timer set at 60fps where as the windows run loop is not timer based and runs as fast as your gfx card can go. This really brought out the Physics step problems because my windows game would run at like 2000 fps and the physics wouldn't work at all while the iOS version would be really slow and the OSX version would be fast -- even though they used the same physics settings (they shared the same code). My plan to address this is to just tweak it so it feels OK on each platform and not kill myself trying to figure it out.

OpenAL Lacks Decent File Import Capabilities

OpenAL was surprisingly easy to set up for all platforms. The only issue I ran into was that there didn't seem to be builtin support for reading any audio formats - so I just grabbed some code off the internet for reading .wav files without ALUT. I did find solutions that involved using iOS/OSX libraries, but I wanted something that would work across platform. Eventually, I plan on adding the ogg vorbis file libraries and using those to load compressed audio files.

Blender? I barely know her!

The next step after I got the basic physics working with some silly sounds and keyboard/mouse input, was to create some models in Blender and get them in game. My idea was simple - create a platform object that had two meshes, one as the actual mesh and one that was the physics mesh. Sounded simple but was actually pretty crazy. Turns out making an object with two submeshes is actually no big deal. You just enter into edit mode for the object and select each mesh in turn and assign them to different materials. I named one material Platform and the other Physics. Then in my Ogre code after I imported the model I looked for the submesh with the Material name "Physics" and used the vertices from that Submesh for the Box2D Chainloop physics hull - oh yah, you have to use the latest version of Box2D from the repository to get this nifty hull type. The crazy thing about this process was I had to walk the edges in the Physics mesh to form a closed loop for the Box2D hull. Fun fun.

The biggest hiccup with Blender was getting the model with the two submeshes into Ogre with all the vertex data intact. When I used the latest version of Blender and the latest version of the Ogre exporter for Blender the files that were generated used shared vertex data, and when I tried to read that shared vertex data in Ogre it didn't exist! Crash-o-la. Solution? Use the older version of Blender and the older exporter that doesn't use shared vertex data and it works. Boom.

Silverback

I chose to use the Gorilla GUI for Ogre because it was two files! - and I saw it in action in the Ogre forums and had to try it.

It's super basic and you have to do everything, but it is fast and once you get a feel for what it can do it just makes sense. I also found the demo console app to be really handy.

In the End...

I just didn't have enough time to finish. I wasn't supposed to be working on this alone, but my other teammates had other things come up. None of the art or animations were made and I never added the background music and ambient sounds that would have really helped it. Of course, even a legit background would have helped!

I learned a lot from the experience and did have fun and plan on bringing the game to a releasable state in the future. Until then I will return to OGE, My First Planet and Spacescape dev work in my free time.