Featured Post

Converting Java is Fun!

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!  

Read More

Converting Java is Fun!

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

0

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.