Wrapping up a Java2D game: custom fonts and transparent pngs

A while back (turns out it was about 8 years ago) I started working on a simple 2d game in the style of Nintendo Game and Watch LCD games that were popular in the 1980s, but I never finished it completely.

I dug up the source and committed it to GitHub in its original state, how I last left it, and then took a look at wrapping up the last few issues and adding finishing touches.

Here’s the source for the game, and here’s the source for a generic 2d game framework that I abstracted from the game as I was developing it. Here’s a couple of posts from when I was actively working on developing this, here and here.

There was a couple of bugs in the animation that I never fixed, and I wanted to polish it up a bit.

It never really had the look of an old monochrome LCD display, so I first changed the background (using a color dropper to pick a color from online photos), but then realized none of the images were transparent so it ended up looking like this:

 

 

Notice the bank on the top-left now has the first of the sprites updated to add transparency. I did this by adding an alpha layer in Gimp per simple steps here. I updated each of the image sprites to resave them as PNGs with a transparent layer.

The end result now looks like this:

 

 

 

 

 

 

 

 

The LCD segment font is from http://www.styleseven.com/. To load the custom font, use:

[code]
ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, System.class.getResourceAsStream("/fonts/digital-7.ttf")));[/code]

And then when you need to use it, create a new Font using it’s name and you can use it in place of any regular system font:

[code]
g.setFont(new Font("digital-7", Font.BOLD, 20));
[/code]

Updated results for the game are here and the 2d game engine here.

Oracle lays off Java Evangelists – what’s going on?

Not sure what’s going on over at Oracle, but news on Twitter is that they just laid off (what sounds like) their entire Java Evangelist team:

Other than this article on InfoWorld there’s not much else to go on, but from various tweets from some of those involved it seems to involve Simon Ritter, Cameron Purdy, Jim Weaver and others too. That’s a lot of top Java talent. Would love to hear what’s going on at Oracle right now. Seems odd timing as well, 1 month before JavaOne?

Oracle: Google has ‘destroyed’ the future of Java on mobile devices

As a long time Java developer (since 1996) and advocate of the language and platform, the legal action from Oracle against Google and Android deeply saddens me. If anything, what Google has achieved is nothing but incredible and outstanding, as they have turned an arguably Java based/influenced platform into the most successful mobile device platform by far, something which Sun and now Oracle were never able to achieve.

Instead of crying over their lost opportunity, Oracle should be doing everything possible to partner with Google and license Android and/or adopt it as the mobile device platform for Java.

The joke that is Java ME needs to be ditched. It’s had it’s time. It was on almost all (what are now called) feature phones sold years back, but no-one apart from (some) Java developers knew this, so now even that potential success is nothing but a lost opportunity.

Please Oracle, do yourself a favor, preserve what little respect you have left from your loyal Java developers: if there’s anything being destroyed here it is our faith in you as a Company and as the guardian of Java.

Ditch Java ME, and license Android from Google as the new Java ME.

Android is what Java ME should have been from day one.

Local javac path issues on older OpenShift WildFly8.2 based project

I have an app that I created a few months back on OpenShit based on the WildFly 8.2 cartridge. Locally in Eclipse the project builds and compiles fine, but executing mvn directly or in Netbeans (which also builds using your mvn pom.xml), it fails with an error regarding a path to javac:

-------------------------------------------------------------
COMPILATION ERROR : 
-------------------------------------------------------------
Failure executing javac, but could not parse the error:
/bin/sh: ${env.OPENSHIFT_WILDFLY_DIR}usr/lib/jvm/jdk1.8.0_05/bin/javac: bad substitution
1 error

This is obviously setup for building specifically in the OpenShift environment with this property defining the path to javac:

<maven.compiler.executable>${env.OPENSHIFT_WILDFLY_DIR}usr/lib/jvm/jdk1.8.0_05/bin/javac</maven.compiler.executable>

There’s a few posts and discussions about this (e.g. here and I suspect this is related), but I’m guessing the version of the pom.xml I have is older and been changed recently. I created a new OpenShift WildFly based project to compare the created pom.xml, and these two properties are no longer in the pom.xml file:

<maven.compiler.executable>${env.OPENSHIFT_WILDFLY_DIR}usr/lib/jvm/jdk1.8.0_05/bin/javac</maven.compiler.executable>
<maven.compiler.fork>true</maven.compiler.fork>

Removing them fixes my local builds, and pushing the code to OpenShift still seems to build ok too.