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.

Adding transparency to existing images using Gimp

To modify an existing image so it has transparency in Gimp, here’s a quick summary of steps from this section of the Gimp docs:

  • Open the image
  • Add an alpha layer: Layer > Add Transparency > Add Alpha Layer
  • Show the Channels dialog: Windows > Dockable Dialogs > Channels – you now see one of the original image and the Alpha layer
  • Select the original layer, then use the Eraser tool to erase the original background from the image (the part that you want to be transparent).

 

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?