Featured Post


It’s been a while since I posted anything to the blog as I tend to use Twitter these days for gamesy stuff but I thought I’d recap exactly what I’ve been doing these past few months in Pumpkin Land. I’ve been keeping busy converting various bits n bobs of Java, frameworks and libraries to C#, in an attempt to release some of the awesome games from Puppy Games on the iPhone via the awesomeness that is Mono / Mono Touch. I’ve worked with the Puppy guys in the past, bringing Ultratron to the Xbox 360 via XBLIG / XNA Games Studio and entering a Droid Assault WIP to the 2011 Dream Build Play contest (we didn’t win). Previously, I’d used a hybrid approach when dealing with the Puppy code in XNA. A bit of their stuff, a bit of mine, the Content Pipeline, etc, in a mash up of conflicting styles and designs goals. And while this worked, it involved a fair amount of hacking, bug hunts and lots of head scratching trying to fit square puppies in round, pumpkin shaped holes. So, this time would be different! I’d convert the whole Shaven Puppy Games Library (SPGL), their support tools, their reflection based resource loaders, their GUI, the lot! Oh, and therefore any bits from The Lightweight Java Game Library (LWJGL) that the Puppy engine utilised. It would be a fairly complex conversion but ultimately make converting the games much, much easier. I started sometime in October, maybe the 14th and by mid December I was done. A minimal SPGL proof of concept app running in the iPhone simulator on my brand new shiny MacBook Pro. Sprites, music, SFX, arbitrary geometry, text, touch all present and correct. The actually journey from Java source to running appplication wasn’t too bad. A few folks commented that it should be a breeze to convert to C# due to the similarity of the languages, and while mostly right, there were a few bumps along the way. Firstly, I ‘needed’ a new Mac. Mine was old and slow and the keys were silver instead of the new flat black ones and, ok then, I just wanted a new one. Then I had to set up the Mono environment which was quite difficult for someone that bootcamped Windows pretty much exclusively on the old one. Where do the libraries go? Ah, Nant is compiled with MCS and I want a v4 compler so I need DMCS, blah, blah, blah. I shouldn’t complain though as without Mono none of this would be possible. And it really is an outstanding piece of work created by magic, pixie dust and lots of hard graft by the folks at Xamarin Next was down to a combination of too many late nights and grand incompetence on my part. Trying to run my Mono code on the iPhone. That’s desktop code. On the iPhone. What was I thinking!? Once I realised what I fool I’d been I created some Mono Touch solutions, referenced the correct framework libs and we were good to go. Then there was all the Java bits ‘missing’ from C# that I needed to either duplicate or rewrite. I chose to duplicate and spent some time in java.nio, java.io etc dragging more and more bits of core functionality in until finally drawing a line, adding some NotImplemented exceptions and commenting out some stuff that probably will never be called anyway. Generics are different. A bit of head scratching there. Annotations / Attributes close enough to hack around a solution (no generic attributes allowed in .Net). Reflection pretty much the same really just different keywords so I either added extension methods or changed the source code to be more Dot Netified. Default scope rules are different, no biggie though. Checked exceptions – gone. Iterators to foreach mostly ok (except for list modifications while traversing) and probably a few others that I forget now. I must thank Cas Prince for putting up with me hassling him late at night on Skype about Java syntax or functions or why my sprites aren’t showing / are the wrong colour! So there we are. All ready to go in the new year, hopefully with some cool games for desktops, mobiles and tablets. Cas will do the Java side and I’ll port to iOS. Merry Christmas. PS – I’ve also got a Windows Phone 7 / Xbox ports done now too. Happy days

Read More

Converting Java is Fun!

Posted by Paul | Posted in Uncategorized | Posted on 30-11-2012


The same way I find running fun! It hurts a lot while I’m doing it and I’m glad when it’s over but there’s a certain satisfaction followed by a warm glow after.

I first dabbled with the whole Java/C#/Puppy/Pumpkin conversion thing about 5 years ago now I think, just after the release of XNA Game Studio 1.0. Being a jobbing C# developer it sounded great to be able to use the same language to write cool games. I’d spent a short time with the fledgling game library and already converted my existing C++ engine to it and developed my first XNA game, Doppelganger.

Around this time I’d been playing a fair bit of Droid Assault and thought how cool it would be to get it on the Xbox and after a bit of back ‘n’ forth with Cas, it was decided I’d convert the games as is – no new art and minimal design changes – cheap as chips basically. Even at this early stage we didn’t think XBLIG would be a massive success financially so we went for quick and dirty.

So, there I was, eagerly hitting refresh on the Send/Receive email button in Outlook when the email from Cas arrived. Yay, I though, then “Ultratron source code” hit me. Now I liked Ultratron, but it was no Droid Assault, bah, I though! But Cas was right. It was a MUCH simpler game and would be MUCH easier to convert. It would be the perfect test case and hopefully we’d hit the launch of XBLIG too.

Reading through the code it was obvious there were a few support libraries that the game used – namely, LWJGL, SPGL, LWJGLApplets. Hmm, that’s a fair bit of code there, I thought. And as I began trying to get a handle on the way it all fit together I got a bit despondent. And, converting the cool little game suddenly became a much larger project.

But then I had an epiphany! I’d already got a game engine, written in C#, using XNA Game Studio, targeting the XBox. Let’s face it, Ultratron is a simple game – it’s Robotron with knobs on – what would we need? Entity system? Got one. Menus? Those too. Particles and effects? Yup, all in the Doppelganger engine. XML parsing – close enough. So I had a plan – I would extract all the data from the XML scripts, the entity behaviour from the Ultratron code, bolt my menu on, tweak the particles and add the XNA specific bits like Controllers and Profiles the the Xbox audience would expect.

Conversion was rapid. My engine was pretty basic but it had all the guts required and the only thing I had to change was the collision detection as the Xbox CPU choked a bit on the exiting approach. Around this time I was preparing to emigrate to New Zealand so things were mad but I completed the conversion a few days after XBLIG went live. The game received some fairly good reviews (2nd I think in Retro Remakes early round up of the service) as well as some (valid) criticism – folks missed the Puppy menu system and some would have liked a super duper HD widescreen version. It sold shockingly however – I think we split a cheque for a couple hundred dollars early on and that was about it for it.

But I’d got the bug and after tidying up a few things in a couple of updates (including new Menu) I was eager to get my hands on the Droid Assault code. Eventually, the email came through! “Titan Attacks source code”, bah * 2. BUT, it was mostly more of the same and again much simpler than Droid. I followed the same process as for Ultratron but this time things didn’t go as smooth. I struggled a bit with some of the code features of Java, I couldn’t get the sprites to draw in the correct locations (stupid hotspots), Titan was my least favourite of the Puppy games so enthusiasm dipped a bit and then my world turned upside down MASSIVELY and development stalled. Titan was pretty much dead in the water. It was maybe 85% done but I’d got zero time to dedicate to it and even less desire.

But the life changing event didn’t last forever and eventually (maybe a year?) I had some time to kick things off again. And what do you know Microsoft go and announce a Dream Build Play competition and Cas is up for Droid Assault as our entry. The stars align and I’ve got the code mojo back so I begin the conversion…

…it’s a disaster. The code just doesn’t fit my engine. I introduce too many bugs during the conversion and I’m gutted. I’d been waiting to convert this game for ages and then I go and bugger it up?  I wasn’t totally beaten yet though – I loved the game too much to give up and I wanted to give it a real go. So I went at SPGL and LWJGL with an XNA sized lump hammer. The code was rough and hacky and I had to change a lot of the syntax (but not as before, the behaviour) and blimey Charlie I’d got them into some sort of compilable assembly. This was probably about 2 years ago so details are a bit fuzzy and I’ve no idea how long it took but, there it was, a little droid, doing his little animation dance on the screen – he was upside down and in the wrong place but I didn’t care.  A sprite, on screen, using SPGL, LWJGLApplets and Droid Assault code. I finally fixed the sprite positioning bug and even wrote some Java utils that wrote the map data into a format I could use. And by some miracle, I got maybe 95% of it converted. There was some work to do with the controls but it ran and you could play it and transfer and shoot stuff and…..it sucked on the Xbox. Like 1 or 2 FPS sucked.

“Garbage, that is”, I confidently predicted but it wasn’t. Method call overhead in the sprite engine maybe? – I made public fields EVERYWHERE. Better, but still not good enough. The first ten levels were playable but not much more – I posted some images on Twitter and even upload a YouTube vid but something was rotten in the core of it. Eventually I tracked it down to the enemy droid AI and the map renderer!! I came up with various changes to both systems but nothing worked well enough to get it performing acceptably. I submitted the 10 level demo to the comp but didn’t hear anything back from Microsoft – I showed it at GameCityNights in Nottingham and folks liked it but I wasn’t happy with. It needed MAJOR work, most probably a rewrite of the offending systems and I was totally burnt out. I spoke to Cas about a few ideas but Revenge of the Titans was nearing release and things were about to go mental there so Droid kind of got put on the back burner.

At this point, the scoreline read success 1 – 2 failure. Boooo!

After a period of recuperation of about 3 – 4 months I’d got the bug again – I found the  Titan Attacks source code snapshot, ran the new Java Conversion Monkey tool at it and had the lot converted in 3 days! 3 days, part time, the entire game. And it worked. The work that went into the Droid converison had finally paid off – I posted a tweet – and then BAM! Cas replies, “We’ve just given Titan a massive widescreen overhaul – with HD graphics” – none of it compatible with the engine stuff I’d done. “Never mind”, he says, “check out this Android version. What about doing that?”.

So, I started again. With AndroidSPGL – And I did it all. Properly this time – no XNA hacks in there. I did bits of Java, LWJGL and all the resource loading tools. It was hard work, late nights, head scratching but I reckon about 2 months or so and I’d got it done. I did the test harness too and got it running in the iPad emulator – I did a Windows Phone 7 version for kicks – it all just worked now.

Score most definitely 2-2 I thnk :-)

I just needed an AndroidLWJGLApplets now but it never came. Revenge of the Titans took off on Steam, rather well, in fact and Cas was swamped with that. And then life gets in the way for me again and I have to cope with that for about 4 months again.

Things are a bit messy so I reassess:

- Ultratron - done
- Titan Attacks (pre-widescreen) – done – uses hacked XNA version of SPGL / LWGL
- Titan Attacks (post-widescreen) – some done - uses hacked XNA version of SPGL / LWGL
- Droid Assault – 95% done with crippling performance problems - uses hacked XNA version of SPGL / LWGL
- AndroidSPGL - done (for iOS / Windows Phone 7)
- AndroidTools – done (for iOS / Windows Phone 7)

What was missing? – there’s desktop SPGL and desktop LWJGLApplets - hmm, I’d already done a bunch of SPGL work for Android and a bunch of ‘hacked’ LWJGLApplets work for DA and TA. So I set about doing the full desktop versions of the Puppy libs using MonoGame - no XNA style hacks – properly this time, like the Android version.

And they are pretty much done…

SPGL 100%, LWJGLApplets is being tested right now. Just need to do the glue layer that sticks a Puppy game to a MonoGame game and add sound back in. Then, I can get the latest Titan Attacks code (it’s had some updates recently) and run the conversion monkey over it!

Phew, it’s been quite a ride!


Write a comment

You must be logged in to post a comment.