Tuesday, September 23, 2014

NEW Spacescape gets HDR, OSX and more

Version 0.5 of Spacescape has been released -  Download it!



If you were waiting for Spacescape to run on OSX, your wait is over! Not only is it over, Spacescape got some requested features that are really cool.

v0.5 FEATURE LIST

  • Support for OSX
  • HDR mode for working in high dynamic range and exporting 32bit per channel .exr or .dds skybox images.  Also allows for using HDR billboards (.exr)
  • Import billboard data file to manually specify billboard positions, brightness, distance and  colour
  • More export options! Export now adds support for UNREAL (3d cube map with correct rotations and .dds output), UNITY (correct naming), SOURCE (correct naming and .tga output)
  • Debug box option for those trying to determine the orientation of the exported skybox faces for importing into a different engine
  • Converted billboard file field to support a browse button so you can choose any file on your computer instead of having to put them in the media/materials/textures folder

About this HDR thing..

You can thank the good folks at NVidia Demos for financing the addition for a recent demo they released!  You can see part of the Spacescape generated HDR starfield with actual star values, positions, brightness values, colours and some generated nebulas around 6:54.


It's really cool, but for most games you'll probably stick with non-HDR because you just don't need the extra data.  HDR skyboxes are cool when you want to accurately adjust the exposure in your game for, say, a daytime scene when the stars are not visible because the atmosphere is so bright, and then as night comes and the atmosphere is no longer bright the stars become visible.  Keep in mind a few things:
  1. Use HDR billboards in .exr format or the outlines of your billboard stars will get too blown out as you adjust the exposure.  Some sample .exr billboards are included in the app or you can make your own in Gimp or Photoshop.
  2. Use the new HDR Power field to push most of your stars into the background if you are using randomly generated star positions, otherwise use a data file.
  3. If you use a data file to specify star data, the input is a csv file that requires an X, Y, Z, ABSMAG, and DISTANCE.  All these values are based on actual star data and there is a sample data.csv file with a few constellations in it in the Files section of project.  You can also find a massive star database at http://www.astronexus.com/hyg
  4. Use HDR Multiplier to make background stars and nebulas really faint and near stars bright
  5. A good range for HDR brightness values is between 0 and 10, even though the colour values for stars is from 0 to 255, when in HDR mode those numbers are actually converted to the 0 to 1 range then the HDR power function is applied and the result is multiplied by the HDR multiplier.

There's lots left to do

And that's an understatement.   Spacescape is nothing like the final tool I want it to be. I want to implement a simple mode for non-wizards, and a skybox library - a way to share skyboxes from within the app amongst many other things.  I'd also like improve the way layer masks work and possibly add terrain and planets!

Kickstarter?

To add all the features I want would take a lot of time.  I was only able to add in these recent features because Nvidia was able to help pay for those hours.  So I'm considering putting up a kickstarter or indiegogo project to get the other features funded.  Maybe nobody will notice? On the other hand, Spacescape has been downloaded 41,000 times since I posted it in 2010.

Monday, August 11, 2014

Adventures in Phaser.io

With the Christian Game Dev contest coming up, I decided to use a game engine I've wanted to use for a while.  There's a web game engine called Phaser, written in Javascript that uses Canvas or WebGL for rendering and HTML5 for audio.  The documentations and community is awesome, they even have an IRC chat room where you can get instant community support!

The Competition


For the competition theme this year, you could pick from one of three verses.  I chose the Hosea 6:6 verse which says something like, "For I desire mercy, not sacrifice, and acknowledgment of God rather than burnt offerings."

Yer a pirate yarg!

In my game you're player is a pirate and you go around collecting treasure and fighting while running from the King's men.  At one point you get caught, told the truth and are given the option to be pardoned and join the King's men or be banished.  After you join the King's men you are given a new sigil, clothes and a mission to recover the King's treasure/keep the peace and offer the same deal to any other pirates you encounter.  Get it?  I know, I'm no C.S. Lewis, but it's one of my favorite CDN game ideas so far.


Booty!
I spent too much time on creating assets and just figuring out how to work with Phaser, and then went on vacation half way through the allotted time, so I never finished it.

Pirate sprite sheet

I used Tiled for making the levels, photoshop for all the art and did my coding in Sublime.

Custom props!

In the end I would say that Phaser is a good engine for creating a web game.  It has just about every kind of example you need to make your 2D game.  The downside of Phaser, for me, is that it is written in Javascript and I have yet to find an editor that I really like for Javascript.  XCode has ruined me with it's code completion and super easy navigation.  With Phaser, I was constantly flipping back and forth between the API in browser and Sublime, where as in XCode I would use auto-complete or cmd+click my way to the header files for whatever I was working on and rarely have to use my web browser for anything.  Sooooo much faster!

If you have to chose a platform for a web game, I'd say Phaser is one of the best I've seen, but if you don't really care so much about open source and not needing any plugins you can always join the herd and head over to unity3d.com

Tuesday, April 1, 2014

3D Puzzle Game "PZL" Released!

Back in, oh, last year I threw together a game for Ludum Dare 26 called "Puzzle Cube" that was built entirely on Ogre3D.   Shortly after, I ported that game to iOS and showed it to a friend who really encouraged me to develop it into a full-on mobile game with levels, scores, and everything. Since then I've made 30 code commits and added a bunch of features and levels and released it on the iTunes Store  under the official name PZL.  Dayum.
"IT'S LIKE SOME KINDA FRIKIN MAZE"
Well actually, in PZL you control a glowing blue orb that starts at the base of the puzzle tower.  Each level of the tower can be rotated so you can move the blue orb up till you reach the end of the level - and eventually the top of the tower.  Along the way you'll discover tunnels through the puzzle, prizes, and monsters to evade.



The Journey.


So how did a game that started out looking like this:

Ludum Dare 26 - PuzzleCube
Get to this?



First of all, porting to an iOS mobile device when you start out with a Windows build isn't a walk in the park.  In Windows your render loop is probably some endless while loop or frame listener.  On iOS you have an Objective C app that sets up a CADisplayLink callback on a frame interval.  The callback then manually instructs Ogre to renderOneFrame.  Then there's the matter of getting input from the keyboard, touch input, outputting audio, not to mention any kind of networking or saving to disk you might need - ouch!

Let's talk bout some of those -

Ogre3D


I used the OgreDemoApp/OgreFramework for iOS as a base so I had to refactor my initialization code so it worked with the OgreFramework.  I had to pass down some things like the scene manager, camera and window handle to my main game class.  I also decided to make my Game class a singleton mainly referenced through the OgreFramework so I could easily pass down frame render events and input events from OIS, but I probably could have architected it all differently and merged my main game class with the OgreDemoApp class.   The downside of merging would have been that I would have a lot more code in that merged class that wouldn't get used on say the Windows version.

Also, I had to remove all the OgreBites tray code and the majority of the camera manipulation so my game could control it instead.

Audio


Things got a bit hairy when I needed to expose some things to C++ code that were only available in Objective C, namely audio, keyboard input and session data (stored in NSUserDefaults).

I chose to use the SimpleAudioEngine for audio which comes from CocosDenshion (Cocos2D also uses this).  It's a really simple audio player that easily handles background and event audio.  So how do you access an Objective C class from inside game code which is written in C++?

What I did was create a GameAudio Objective C class:

The implementation file for GameAudio (named GameAudio.mm) has my functions that call the SimpleAudioEngine class like so:

To call those GameAudio functions from C++ I provide another header file called GameAudioInterface.h with headers for the functions in GameAudio.mm


Keyboard Input


WARNING HAX.  I created a GameKeyboard Objective C class with an invisible UITextField added to the main UIWindow.


Inside the implementation file I provided functions to show/hide the keyboard and called functions in my main game code when a key was pressed.  Because the game code used OIS I had to map every character to the OIS equivalent. YUCK.


Lastly, I exposed the keyboard show/hide functions in a header included in the C++ game code called


Hopefully that code saves somebody some time.


Other  Objective-C Stuff n' Thangs


OK besides audio and keyboard libraries I used NSUserDefaults to save some basic settings and the excellent Scoreoid API for saving player scores.  For those who are unaware, Scoreoid lets you save scores for free using their platform agnostic API so this means if I port the game to Android I can access the same score data in the future.

Lastly, I implemented the Chartboost SDK to serve ads.

Technology Used


Graphics Engine: Ogre3D
GUI: Gorilla
Input: OIS
Audio: SimpleAudioEngine (CocosDenshion)
Scores: Scoreoid
Animation: CppTweener
Network: AFNetworking


That pretty much about sums things up as far as the development goes.  I do plan on adding some more gameplay elements in the future if the game has enough of an audience to warrant updates.

You can download PZL via the iTunes App Store on your mobile device or click the link here:
https://itunes.apple.com/us/app/pzl/id812626888

Thanks and enjoy!

Saturday, January 11, 2014

My Fav Games 2013

Before the game list I'd like to say the obvious - I've been really busy being a dad and running a business (http://inthepin.es) and that has left me with little time to play or make games this year.  I've have done a TON of iOS development and a good bit of web dev and am about to release a small puzzle game for iPhone/iPad soon - will post about that when I do. With that out of the way -

A new year is upon us. Again.  So what games were awesome in 2013 for me?



Natural Selection 2 - naturalselection2.com

I spent a good bit of time playing this, mostly because I don't have enough time to commit to an MMO and I like to be able to jump into a quick game and out.  The dev team has also been putting out some impressive updates to the game that have kept it interesting and fun.  Also, the e-sport aspect of this game is immensely entertaining as well, and the matches have made appearances on twitch.tv front page often for good reason.





Mass Effect 1 - 3 - masseffect.bioware.com

This game was the most compelling single player game that I played in 2013 - I had to buy it after it went on sale and after hearing how much the ending upset so many people.  Load of fun and graphics are pretty good.  If and when this franchise continues I will be watching to see if I want to continue my characters.




Minecraft - minecraft.net

My 4 year old son loves this game and because of that I have gone through the hell that is minecraft mod setup on multiple machines and servers.  It has been worth it though, and has provided us a ton of fun multiplayer gaming and I would even say it has taught my son how to use a mouse and keyboard.



Civilization V - civilization5.com

This game has remained on my favorites list because it is so casual and addictive and sometimes I don't want to get my heart rate up trying to shoot things in a twitched based game.  For casual and still awesome I recommend Civilization.


As for honorable mentions,  I also tried Borderlands, various X3 expansions and a few mobile games, but nothing really kept my attention for long except those listed above.  Hopefully I'll have more to post soon after releasing this mobile puzzle game I have in the oven.

Sunday, August 18, 2013

Christian Game Dev Speedgame 2013 - Salvation

The theme for this year's Christian Game Dev Speedgame was "Salvation".  My idea was to create a Faster Than Light clone where the goal is to escape the blast radius of an exploding star.


Source Code: https://github.com/petrocket/salvation

Download Game (Windows only sorry):
Download From Sourceforge.net

Live broadcasts during speedgame:
http://twitch.tv/petrocket

The Storyline

Ye Title Screen with random background!

Your uncle sends you a message one day saying the star in your solar system will explode and he gives you a space ship called "Salvation" and tells you to fly it to the outer-most planet in the system to escape the blast radius.  Along the way you may need to fight hostile attackers, upgrade your ship, and complete various missions to fund your journey.  Also, you should pick up passengers along the way to get as many people to safety as possible.

The Gameplay

Space battle - go.

It's all RTS-style gameplay using menus with no first person stuff.  You manage your ship's upgrades and passengers and plot a course out of the danger zone.  Randomly, when entering a new system you will encounter a hostile ship and you can choose to engage or run.  The game code also randomly generates missions in each system in which you deliver cargo, eliminate hostile ships etc.

The Content


Planets, spaceships, stars oh my! And this time I made it a priority to include audio also.  I also spent a good bit of time on the gui because I knew it would take up a lot of the screen most of the time.  Given enough time I would have created space stations, futuristic cities and asteroids.


Skybox look familiar?  I tweaked some spacescape skyboxes for the game and think they add a lot.

One thing you may not see so well in the screenshots is that I added some bokeh, shadows and animated screen lines on top of everything, something I've never done before but think it turned out well.

This game was brought to you by

Graphics: Ogre3d
GUI: MyGUI
Audio: SFML
Input: OIS

Content created with:

Skybox: Spacescape
Spaceships: Blender3d
Planets: PlanetCreator
Editor of choice: Photoshop

The Good The Bad The Ugly

Ogre3d has always been a nice engine to work with and this time was no exception.  It rarely gives me grief and there is so much help online that I found samples for just about every problem I ran into.  

Example:  I wanted to overlay bokeh and shadow box images on top of the scene but under the GUI.  This was a problem because MyGUI is hardcoded to use the overlay renderqueue, which is also the render queue that overlay in Ogre are hardcoded to use and you can't change either without coding the change into the libraries themselves.  
Solution: Just create your own Ogre::Rectangle2D entity and manually set the renderqueue to be just before the overlay render queue. #boom.

MyGUI has come a long way since a few years ago when I used it last.  It has a layout editor and skin editor that are really slick.  The biggest issues I faced with MyGUI were the lack of support for Ogre Materials and the lack of tutorials, code snippets online.  Some day I would love to write some howtos for MyGUI basic implementation.

SFML is a great audio library.  It is EXACTLY what I needed because it works cross platform and was super easy to set up, literally a couple lines of code to have background music and effects playing.  Underneath it uses openal and sndlibrary so it is based on some solid code.

The last super great find was the Planet Creator tool.  This thing is amazing, it randomly generates planets based on a large selection of templates (planet types like arid, earth-like, moon-like, etc.) and then it exports the texture maps, normal maps, specular maps and more!  I'd really like to see spacescape and this planet creator get bundled together somehow to make some epic space game content creator.

Other Stuff

I've actually done a lot more work on the puzzle game and I expect to have that out on the app store this fall.  No OGE updates or other game updates so far.  I am considering entering the August Ludum Dare, so if you are going to participate I'll see you there!

Thursday, May 9, 2013

Ludum Dare 26

Ludum Dare 26 Entry - Puzzle Cube


Ludum Dare 26 - PuzzleCube

I decided to enter into the 48 compo Ludum Dare 26 challenge where you make a theme-based game in 48 hours.  The theme was minimalism, and I was going to apply that to my game by making the game simple and the look simple too - never did get around to audio.

You can download/play the game on Windows or OSX (sorry Linux) here:
http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=23254

It's a simple puzzle game where you try to get the ball to the top of the cube by maneuvering it around and through the cube.  Also the rows of the cube rotate, though in this version they don't really work as intended and the player does not move with the rotated rows.

The game was built with Ogre3D in Visual Studio 2010.

I also live streamed my 5-6 hours of game dev on twitch here:

Since then I have converted the game to iOS for touch devices and implemented most of the missing features, so that may be released as a free or cheap game soon.  Here's a screenshot of the iOS version, still needs lots of luv, but it does have sound, rotating levels, infinite random levels and animations for all the movement.

iOS version


OGE & Planet Stuff

I haven't touched this in a while since becoming frustrated with the stuttering issues.  I did make that physics sample that only has grid lines in it and when moving around the stuttering happens even in that minimal program.  I haven't been able to solve it yet and got preoccupied with working on our other iOS game and client work.

Here's a couple updated screenshots of our iOS game with the new characters and graphics

iPad

iPhone


Wednesday, December 12, 2012

OGE And Game Updates

Lots of game dev happening this fall, but most of it has been on our 2D port of the fireflies web game we made for the CDN contest last summer.  The team at Bearhanded (where I work) decided to take our web game and make it a mobile game to be released before Christmas.  Needless to say we decided to vastly expand on the original game, adding many more game objects, levels, pizzaz and eye candy yada yada.

Do you recognize the first level from our web version?

The graphics got a major overhaul, and as a minor note the characters in these Beta screenshots do not represent the final characters - those are still in progress.  We also decided to have 3 trees in the initial release; the first tree has daylight levels in the middle of the day, the second tree levels take place at dusk and the third at night, which means we're going to add a whole new aspect to the game - dynamic shadows and lighting!

This level is ALL developer art, but it shows the colored lights and shadows effects.

There will also be pulley systems, bounce pads (disguised as red mushrooms), sap that you can sink into, enemy pushers, bombers, moths, worms, tubes, torches, cannons and maybe even more if we don't say "when" soon.  We've added so much that we had to push back our release till early 2013.


This will be our companies first iOS game release so we're trying not to get our hopes up and just to make a game we all can be proud of, though recouping our investments would be nice.

Ye OGE (Open source Game Engine)

ye link

While all this 2D stuff has been going on, I've been working with Ralph on upgrading the libraries OGE uses and improving on the CMake build system.   At this point, it appears to be working on windows 7 and linux, but not on OSX.

What's been holding back progress on the planet?  Well, I've kinda decided to give OGE a real run for the money and see if I can't make it work before giving up and rolling my own, simpler game engine.  I've got the latest planet stuff running in OGE, and have been creating sample projects to track down various major bugs like random thread/memory crash bugs and physics stutter bugs.  Ain't no fun to play a game that stutters and I've noticed that stuttering seems to be a common problem when working with physics engines. If you're a physics or threading guru I would love for you to take a look at those parts of the OGE code.

This is my temporary MyGUI implementation in my planet test suite with the latest OGE (bogey tracker broken in this build!)

This is my little physics sample that I hope will help me nail the stutter bugs.

I've also added a version of the OGRE profiler to OGE and added optional profiling blocks to all the major systems for now.  It doesn't really work like I would like, but it's better than nothing for now.

No fav games of 2012 post because I mostly just play one game - Natural Selection 2!  They finally released it and it is super fun.



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.

Wednesday, July 6, 2011

Let there be Bogeys

bogeys
(click to enlarge)

It hasn't been very productive these last few months. Got the usual family stuff that is, obviously, more important than this - but what I have done is experiment more with MyGUI and added bogey trackers to some mine objects.

The bogey trackers are actually 2D GUIe widgets and each corner of a box surrounding a mine is it's own widget. The performance ain't hot let me say that much. I'd like to also try 3D bogey trackers and actually put billboards in 3d space around the targets, but I kinda doubt that will be any faster.

I've also tried to smooth the input and framerate a bit more. In the process I implemented a mouse look system for the ships that is similar to the one in X3.

In the process I broke my multiplayer input so now client ships can't move, and there is still a bit of jitter when moving fast, ugh. I plan on attempting to fix the network bug and then do some renovations to the lasers & thrusters. After that it's some basic menus - joy! One of those menus should be a menu to jump to another planet or solar system, so that will open a whole new can 'o worms.

Here's a little vid I recorded - just shows the bogey tracker.

Sunday, February 20, 2011

Helpful Mercurial Tips

I spent a good bit of time trying to setup a Mercurial repository server on a Windows 7 Server that uses wamp.

I had to install TortoiseHg and Python 2.6.6 and the latest Mercurial in that order so that Mercurial would add it's libraries to the Python install. All that is important because the library.zip file that comes with TortoiseHg doesn't have the right Python modules you need to make the Mercurial hgweb.cgi work. Also I needed to install mod_wsgi on the wamp server which uses Apache.  Lastly, here is my hgweb.cgi

    #!c:/Python26/python.exe
    #
    # An example hgweb CGI script, edit as necessary
    # See also http://mercurial.selenic.com/wiki/PublishingRepositories

    import os; os.environ["HGRCPATH"] = "C:\wamp\www\hg"

    # Path to repo or hgweb config to serve (see 'hg help hgweb')
    config = "c:\\wamp\\www\\hg\\hgweb.config"

    # Uncomment to send python tracebacks to the browser if an error occurs:
    import cgitb; cgitb.enable()

    from mercurial import demandimport; demandimport.enable()
    from mercurial.hgweb import hgweb, hgwebdir, wsgicgi
    application = hgwebdir(config)
    wsgicgi.launch(application)

Nobody Likes To Fly In Space - They Want To Drive

There are a lot of arguments out there about how much "fun" realistic space physics are and I am a believer that it's annoying to have to deal with so many ways to maneuver and the concept of the ship pointing one direction while flying another with the engines off!  So, I'd like to share with you how I decided to implement unrealistic but "fun" spaceship flying. Oh, and back in the day I did participate in the making of a game with realistic space physics.


Cassini Division 2004

To start with lets consider that most games use some kind of physics engine and those deal in forces primarily so we need to make each of the engines apply forces to the spaceship.  But we can't stop there because that is the realistic way and controlling a for-real spaceship can be so challenging that you don't have much time to deal with anything else like, say, shooting.  I mean, just think about all the controls you have to have in your ship to make your ship rotate in any direction and move in any direction!  Now, I have considered a game where each spaceship has a pilot and a separate player as the gunner, but lets not get distracted...

The easiest way to fly in space besides autopilot is to make it like driving - something that most people are used to.   You see, I want two things when I'm driving:
  1. I usually want to be traveling in the direction my spaceship is pointing
  2. When I hit the gas I want the spaceship to move, and when I let go I want it to come to a stop.

Handling the first issue is simple after you handle the second issue, just make the back engine the biggest and don't go putting big engines on the sides or front.  The second issue is not too difficult either - apply dampening to the spaceship so that it acts more like it is moving through liquid/air than through a vacuum.

By applying the dampening we ruin realistic space physics, but make spaceships easier to control.  Now since the ship is really moving through some kind of liquid/air it takes constant force to keep it moving and we now have an excuse for a fuel gauge and as an added bonus, when the spaceship enters the atmosphere or ocean we can use the same controls just fiddle with the amount of dampening.

Last thing I'd like to mention is the issue of 'max speed'.  When we have dampening then the 'max speed' of a spaceship makes more sense and we have the excuse for putting spaceships in the game with more powerful engines - where with realistic space games you can fly incredibly fast in a tin can with the help of some gravity, you just can't start or stop fast.

Oh, and collisions should work with our physics plus dampening model too and keep all that space debris from moving off into infinity where nobody could tell that it was once part of a destroyed spaceship.

On a more practical note, here is how I implemented the above physics model in OGE with Bullet.
1. Use btRigidBody::setDampening() to set the dampening on the Bullet rigid  body object
2. Use Bullet's internal tick callback to apply constant forces before the dampening is applied:
btRigidBody->applyCentralImpulse(velocity * deltaTime);
btRigidBody->applyTorqueImpulse(angular * deltaTime);

Tuesday, January 4, 2011

A New Year With New Goals?

The end of last year was somewhat unproductive for me on the planet front.  I was looking back at my calendar today and see that I spent most of my time doing real life work and being a dad.  I also spent a lot of free time playing games too instead of making them.

The two things I did work on that were planet related were OGE and Spacescape.  I made the developer list for OGE, and I might be the only active developer for now, but I hope that changes soon.  I spent most of my OGE developer time working on the RakNet networking and Bullet physics systems and have been trying to get a minimal networking example working with a small player controlled spaceship, some exploding mines and a planet.  Let's just say that networking + physics debugging can be annoying and I had no idea that making a spaceship NOT have Newtonian physics in space would be so challenging! - more on that later, maybe.

Spacescape got some bug fixes and minor features and I added the CMake build system to ease the pain for new developers and for me each time I develop on a new machine, especially one with a different OS like OSX. I also got my first and only Spacescape donation woohoo! and a bunch of feature requests, support requests and compliments.


On the table for this year are:
- Finish the OGE networking space example
- Re-asses and tackle placing objects on planets (vegetation, buildings, players etc)
- Fix planet underwater shaders
- Add simple clouds to planets
- Make the networking space example into a small game
- Release the planet plugin source
- Port Spacescape to OSX
- Divide Spacescape into "basic" and "advanced" modes so it is loads easier to use for the casual user.

Other possibilities include:
- Use acko.net method for computing planet normal maps
- Figure out additional light maps so we can have lights on the dark side of the planet
- Re-asses how distance/scale is handled when approaching the limits.
- Form a team of like-minded individuals

Hope you have a great start to the new year!

Wednesday, June 30, 2010

Planet Water Shader Tests & OGE

First of all, I haven't posted in a while because I've been sick, then I got my new dev machine and was busy setting it up and playing games on it and other real life stuff.

So, water for this small planet has been difficult for me and I've tried a couple approaches and have yet to get something I like.

What I want:
  • reflections, refraction, transparency, specular, normal mapping
  • under water fog
  • fog color changes based on depth and distance
Here's what I've got so far (no reflection or refraction)




Video of planet water on YouTube

Reflection and Refraction

There is no reflection or refraction on the water because I don't know how I will manage that on a curved surface yet. I think what I will try first is only doing water reflection and refraction when you're close enough to the water that it appears to be more flat so I can use conventional techniques.

Underwater Fog

To support underwater I applied a fog to the pixel shader for the terrain based on the terrain depth under water.  I have a outward facing sphere with a shader for transparency, normal mapping and specular.  I also have an inward facing sphere with a shader for when you are underwater looking up at the surface from below.

Unfortunately, the fog shader on the terrain does not line up perfectly with the underwater inward facing sphere so you see cracks at the water edge where there is no fog.  I think I can only fix this issue with post processing.

New Game Dev Machine

I got a new developer machine with an i7 processor and Radeon 5770.  I tried to choose a middle of the road graphics card.  You can see the new game dev machine specs and discussion on eggxpert.com

OGE

Lastly, I've spent a some time working with OGE which stands for "Open Game Engine".    I've created a small RakNet plugin for it and have been trying to get a little client/server action going.  This is a potential game engine that I might adopt for MyFirstPlanet, at least in the development stages to do all the audio, graphics, user interface, networking, gameplay, physics, and scripting that I would have to build myself.  It supports OGRE as a graphics engine plugin so I shouldn't have to rewrite any of my graphics code.

I'll try to post again when I have a video to show of the network tests.  It will mostly just be a couple clients on a server flying ships around in space over a planet.

Wednesday, May 5, 2010

Planet Terrain Shader With Atmosphere

Before you read this post, if you have not watched Ysaneya's latest tech demo video go watch it now! It is amazing!

In the previous posts I described and published my latest atmosphere shader and I got some useful feedback and requests for information, which I thought I should include here:

- The atmosphere shader is applied to an inverted sphere that is drawn before the planet. This means that if you have a single atmosphere shell and a planet with no atmosphere shader added to it, then you will just see the atmosphere effect behind the planet. I go into how I've added worked in atmosphere shader code into my terrain shader later on in the post you are reading now.

- In the atmosphere shader the camera and light should be in object space, as should the vertices.

- The atmosphere is still not fully opaque when on the sunny side. It is opaque (not see through) at the horizon and gets slightly transparent as it approaches the sun so some stars still show through which may not be desired. I plan on addressing this later when I add other planets and moons. I'm concerned that if I make the atmosphere too opaque then you won't see the moon or planet (or large space ships!) out there, and if I make the atmosphere too transparent then you'll see too many stars on the day side. I may just end up darkening the skybox as the user gets on the daylight side of the planet, but I haven't gotten there yet.

Now, about the planet terrain. I create an 8 way blend look up table based on terrain slope and height. When the planet is first created I render to texture a medium resolution texture (512x512 currently) that blends 8 textures based on this look up table. When viewing the planet from far away I display this medium resolution texture, then when the camera approaches the surface I blend between this medium resolution texture and a shader that actually blends the 8 textures per frame, which is slower but looks better close up.

Too add the atmosphere effect to my terrain in the vertex shader I basically calculate the amount of atmosphere fog like this:
// atmosphere fog / haze attenuation
float3 camToPos = position.xyz- camPos.xyz;
float camToPosDist = length(camToPos);
float visibilityDistance = min(AtmosphereHeight,VisibilityDistance);
oAttenuation = saturate((camToPosDist - VisibilityDistance)/ (AtmosphereHeight + visibilityDistance));


position - The vertex position in object space
camPos - The camera position in object space
AtmosphereHeight - Atmosphere sphere radius minus terrain sphere radius.
VisibilityDistance - At distance = 0, fog is 0 at distance = VisibilityDistance, fog = 1

In my fragment shader I do this:
// gradient0 is a look up table like atmosphere gradient but two pixels high. 
// Top row is atmosphere gradient and bottom row is sun color gradient
float4 sunColor = tex2D(gradient0,float2(uv2,1));
float4 atmosphereColor = tex2D(gradient0,float2(uv2,0));

// how transparent is the atmosphere?
float transparency = min(AtmosphereTransparency,attenuation); 

// get diffuse amount from 8 way texture blend and apply lighting with normals
// or shadow map/light map
...

// get atmosphere contribution    
float3 atmosphereAmt = (atmosphereColor * sunColor * (transparency + (transparency * shadow)));

// add in atmosphere
outColor.rgb = (diffuse.rgb * sunColor * (1.0 - transparency)) + atmosphereAmt;


I use a constant called AtmosphereTransparency to make sure that the atmosphere contribution is no more than a certain amount. I use 0.3 because it looks OK, but on a really dense atmosphere you might want a higher amount.

Here's the full terrain shader you see in the videos when the camera is on the surface - this is the one I use for Ogre3d not for FX Composer.

void main_vp( float4 position : POSITION,
float2 uv       : TEXCOORD0,

out float4 oPosition : POSITION,
out float2 oUV1    : TEXCOORD0,
out float3 oLightDir : TEXCOORD1,
out float  oBlendAmt : TEXCOORD2,
out float  oUV2    : TEXCOORD3,
out float  oAttenuation: TEXCOORD4,

uniform float4x4 worldViewProjMatrix,
uniform float4 camPos,
uniform float4 lightPos,
uniform float AtmosphereHeight,
uniform float VisibilityDistance     
)
{
oPosition = mul(worldViewProjMatrix, position);
oUV1 = uv;

// directional light
oLightDir = normalize(lightPos.xyz);

// dot product of position and light in range 0..1
float posLength = length(position.xyz);
float3 normal = position.xyz / posLength;
oUV2 = (dot(oLightDir, normal) + 1.0) * 0.5;

// atmosphere fog / haze attenuation
float3 camToPos = position.xyz- camPos.xyz;
float camToPosDist = length(camToPos);
float visibilityDistance = min(AtmosphereHeight,VisibilityDistance);
oAttenuation = saturate((camToPosDist - VisibilityDistance)/ (AtmosphereHeight + visibilityDistance));

// start blending between low res texture and high at 512 units out
float blendStart = 512.0;
float blendEnd = 0.0;
float blendDistance = blendStart - blendEnd;

oBlendAmt = max(0.0, camToPosDist - blendEnd);
oBlendAmt = min(1.0, oBlendAmt / blendDistance); 
}


And here is the fragment shader:
sampler diffTex0 : register(s0);
sampler diffTex1 : register(s1);
sampler diffTex2 : register(s2);
sampler diffTex3 : register(s3);
sampler diffTex4 : register(s4);
sampler diffTex5 : register(s5);
sampler diffTex6 : register(s6);
sampler diffTex7 : register(s7);
sampler blend0 : register(s8);
sampler blend1 : register(s9);
sampler diffuse0 : register(s10);
sampler gradient0 : register(s11);

float4 getBlendedSample8(in float4 weights0, in float4 weights1, in float2 diffUV) 
{ 
// use w,x,y,z order because PNG uses pixel format A8R8G8B8
return tex2D(diffTex0, diffUV)  * weights0.w +
tex2D(diffTex1, diffUV)  * weights0.x +
tex2D(diffTex2, diffUV)  * weights0.y +
tex2D(diffTex3, diffUV)  * weights0.z +
tex2D(diffTex4, diffUV)  * weights1.w +
tex2D(diffTex5, diffUV)  * weights1.x +
tex2D(diffTex6, diffUV)  * weights1.y +
tex2D(diffTex7, diffUV)  * weights1.z;
}

void main_fp(
float2 uv : TEXCOORD0,
float3 lightDir : TEXCOORD1,
float  blendAmt : TEXCOORD2,
float  uv2 : TEXCOORD3, 
float  attenuation : TEXCOORD4,

uniform float AtmosphereTransparency,
uniform float tileFactor,

out float4 outColor : COLOR
)
{
float4 sunColor = tex2D(gradient0,float2(uv2,1));
float4 atmosphereColor = tex2D(gradient0,float2(uv2,0));

// how transparent is the atmosphere?
float transparency = min(AtmosphereTransparency,attenuation); 

// get the texture color and lit value
float4 diffuse = tex2D(diffuse0, uv);
float shadow = diffuse.a;

// FYI YOU MAY NOT WANT TO DO THIS IN YOUR SHADER
// make ambient dark on side where light is
// and light on the side where it is dark
float3 ambient = sunColor * (1.0 - uv2);

float4 blended =  getBlendedSample8(tex2D(blend0, uv), tex2D(blend1, uv), uv * tileFactor);
diffuse = lerp(blended, diffuse, blendAmt);

// now shade based on the normal
diffuse.rgb = ((1.0 - shadow) * diffuse.rgb * ambient) + (diffuse.rgb * shadow);

// get atmosphere contribution    
float3 atmosphereAmt = (atmosphereColor * sunColor * (transparency + (transparency * shadow)));    

// add in atmosphere
outColor.rgb = (diffuse.rgb * sunColor * (1.0 - transparency)) + atmosphereAmt;
outColor.a = 1.0;
}