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!