OpenGL Cross-platform PC/PSP Game Coursework

Last semester as part of the Advanced Graphics module of my CS degree at Hull University, we were tasked with a group project to produce a cross-platform OpenGL mini-game for the PC and Sony PSP based on a specification. The game premise was to move around a 3D ‘maze’ consisting of four rooms and connecting corridors, avoiding a patrolling AI that would shoot you if within its line of sight. The objective was to collect 3 keys to activate a portal to escape and beat the game.

The groups were selected at complete random with 4 members. As per usual, group coursework assignments are particularly difficult due to the extra concerns of motivating members and assigning work and by year 3 of University, you get a good idea on the best way of operating within them to secure good grades. I went in with the mindset of doing as much work as possible after we assigned tasks. Hopefully each would carry out their allocated work, if not, I’d just go ahead and do it, no fuss. Luckily one chap in my group was a friend and he did an excellent job coding the AI, mini-map and sound while I worked on coding the geometry, camera, lighting and player functionality etc.

1

Mini-maze model

Static environment lighting

Static environment lighting

Cross-Platform Limitations:

Having worked with OpenGL and shaders last year for my 3D ‘The Column‘ project, it was some-what limiting when I realised that the PSP didn’t support them and that fragment-based lighting was a no go. With one requirement of the game being a torchlight effect that illuminated the geometry, this would therefore mean that for PSP compatibility, vertex-based lighting would need to be implemented and that meant tessellation of primitives to prevent the lighting looking very blocky and…well very 90’s. Luckily the PSP did atleast have support for VBO (Vertex Buffer Objects) which meant effectively each tessellated model could loaded onto the graphics card only once to improve performance.

Unified Code

An interesting aspect of this project was the required consideration for a consolidated code-base that where possible allowed shared functionality for both the PC and PSP platforms i.e limiting how much platform specific code was used. This was essential since the game would be a single C++ Solution for both platforms.

I designed the code structure based around principles Darren McKie (the course lecturer) described, and produced the following class diagram that reflects the final structure:

Unified Cross-platform Class Diagram

Unified Cross-platform Class Diagram

The majority of game code resides in ‘Common Code’ classes that are instantiated by each particular platform ‘Game’ object. Certain code such as API rendering calls were kept platform specific but made use of the common classes where necessary. A particular nice way of ensuring the correct platform specific object was instantiated was carried out using ‘#Ifdef’, ‘#ifndef’ preprocessor statements and handled by a ‘ResourceManager’ class.

As mentioned earlier, per-vertex lighting had to be implemented due to PSP compatibility. A primitive with a low number of vertices would thus result in very blocky lighting. To prevent this I created a tessellation function that subdivided each primitives vertices into many more triangles. I played around with the tessellation depth to find how many iterations of subdivision could be achieved before inducing lag and was very happy with the lighting result considering there is no fragment shader; a given for today’s modern pipelined-based rendering.

Active Portal

Active Portal

The PSP implementation proved more tricky due to getting to grips with the PSP SDK and having access to very little documentation, however the game was successfully implemented onto a PSP device and ran with decent performance after compressing the textures down and removing geometry tessellation to allow for the PSP’s limited memory capacity.

The game was written in C++ and  the following libraries and software were used:

  • GXBase OpenGL API
  • Sony PSP SDK
  • OpenAL
  • Visual Studio 2012
  • Paint .Net
Advertisements

Hypermorph Wins Three Thing Game Competition

So it’s been a frantic couple of weeks, plenty of course-work to do and last weekend was the much anticipated Three Thing Game competition. For anyone not in the know this is held each semester at Hull University and challenges teams to come up with a game based around three auctioned words per team. Judges then score based on the games relevance to the words and the quality/fun of the game. The competition involves a marathon 24 hour programming session to get your game finished on the day. This one was the biggest yet with 39 teams competing. We really couldn’t have asked for better “Things” because a combination of good bidding and luck meant we came out with “Flying”, “Tank” and “Bombs”. Considering another team got “Teddy bear”,  “Deodorant”  and “Pop Tart” I think we did ok!

Last year we came second with Shear Carnage and and I can say that honestly this year, we really really wanted to win it. This was evident to myself just by the focus we had this year and when the day of the competition came, I think I probably left my seat half a dozen times in the whole 24 hours! In hindsight we probably took it far too seriously and as a result I think it sacrificed a lot of the enjoyment of the competition and resulted in some contention regarding ideas that seemed inevitable considering vested interests and no one leader within the team. I think on a personal note, much was learnt regarding team work and there are aspects of the planning and design process I would do differently next time. Luckily it all turned out worth it in the end and so it’s very hard to regret any decisions, but this was by no means a painless endeavour!

Me on the right, Russ in the middle, John on the left. Lee Stott at the back.

So to the game, Hypermorph is a retro-style side scrolling shooter that takes me back to my childhood days, playing classics such as Xenon 2, R-Type and Menace on the Amiga. Back then the shoot’em’up was a staple video game genre and was hugely popular, now only since the mobile platforms have taken off is the genre again feasible because it’s the perfect style of game to have a quick blast on when wanting to pass a little bit of time. The  thing that’s pretty novel in Hypermorph is the ability for the player to switch between two different forms, a spaceship and a hover tank by simply tapping the screen. We made the game using XNA (C#) for the Windows Phone 7 and coded everything ourselves (no third party libraries).

I produced the art for the game and managing both the art and doing a lot of the programming was a challenge in itself on the day, resulting in most of the art being done in the last few hours. I had a good idea in my head what the game would look like when we were bouncing the initial idea around, however my regret was that I didn’t produce any concept art for it sooner to put the rest of the team at ease; for a long time I think we were left with our own ideas for how the game would look but once I came up with the first concept drawing for the ship, the team were all in favour to my relief!

We had decided to make the game quite dark and moody but with bright weapon and explosion effects to make them really stand out. Additionally, we wanted to make the controls as hands off as possible. We learned from Shear Carnage that using touch too frequently can result in obscuring a lot of the screen so we instead went for a tilt based movement for the player and a single touch to morph between Tank and Spaceship. Importantly we set it to auto-fire constantly since you soon realise that in this genre there’s never a time you don’t want to be firing.

One feature I’m really pleased we put in was the voice effects for powerups and various other things. It adds a lot to the immersion and again, really goes back to the genres roots.

Of course we have plans to get Hypermorph out on both the WP7 and Windows 8 market ASAP but uni coursework is currently being prioritised. At the competition was Lee Stott from Microsoft and guys from the Monogame team. Lee’s encouragement was inspiring and I’d also like to thank him and Microsoft for providing the cool prizes. The Monogame guys were brilliant and we spent a fair time chatting with them regarding getting our games ported to the various platforms, they even ported Shear Carnage and my Robocleaner game for us to show us how easy it is! (albeit there’s some coding required to get them ready for the marketplace).

Ultimately we are going to want to put in a few more levels, enemy types, weapons and powerups before getting it on the marketplace, but the good news is it will most certainly be free!

All in all it was overwhelming and the encouragement we have received from Lee Stott, Rob Miles and the MonoGame guys was great. Ultimately this is why I gave up a career in IT to get into the games industry, because there’s so much satisfaction in putting your heart and soul into producing a game and then seeing others get a lot enjoyment from it. Winning the Peoples Choice award as well as the judges award was the icing on the cake and I’d like to thank everyone who voted for us and gave us great feedback.

Stay tuned for more Hypermorph news soon…

Robocleaner out on Windows Phone

Finally Robocleaner is now available for download on the Windows Phone marketplace. Check it out, feedback welcome. There’s a “try” option to play the first 3 levels on each mode for free and the Online Leaderboards function in the trial mode too.

MS Store Link: http://www.windowsphone.com/en-gb/apps/06793bef-a8f3-4b25-a325-4e12b598f4df

As my first solo title that I’ve worked on it was a great learning process and gave me a good idea how tough it must be being a full-time indie developer, especially if your a one-man team doing design, coding, graphics and sound. It’s certainly encouraged me to continue and it’s a shame that XNA is pretty much being dropped in WP8 since a lot of the XNA specific skills I’ve picked up may not be much use in the future (without Monogame at least).

My aim for the next couple of semesters at Uni with time permitting, is to work on more mobile game titles, likely simpler ones (Shear Carnage) with less physics and AI coding. One thing I learned is that just because you have a cool path-finding or a realistic wall bounce algorithm, it may be technically impressive but it really doesn’t impact the game overall and it’s better probably to make games where more complex mechanics aren’t required to make the game fun. I do enjoy doing AI and the physics side of things but with mobile games, it’s better to get the game done ASAP and out on the market so people can have fun playing it. Next time I’ll be aiming to get two games released in the time it took me to make Robocleaner!