Getting started

So you're curious to explore Blu-Play games? Great! These pages will help you get started.

  1. Introduction
  2. Hello world

Introduction

Needless to say, the Blu-Play platform is like no other. You develop your game with Blu-ray Disc Java, that comes with a lot of restrictions and limitations, but which also have its own advantages over other platforms. Coding a Blu-Play game is about knowing these limitations, and taking advantage of the options you have.

Coding Blu-ray Disc Java

The coding part is relatively easy. If you ever coded Applets back in the day, then you're all set. Because this is essentially Java 1.3 and AWT you're going to work with. There are no other graphics APIs available, such as SDL or OpenGL. And you don't have any 3D APIs available either.

If you have any experience coding MIDlets, then you're also kinda set. MIDP doesn't use AWT, but the methods are all the same with a few minor rewrites.

And if you don't have much experience with Java, you're in luck too! Because this is Java from when it was still a rather simple language. Shouldn't be hard to get started with.

Using graphics files

Blu-ray Disc Java lets you use standard graphics fileformats: JPEG and PNG.

Handling audio

To include music in your game, you will typically turn it into a video file with a black background - or an actually graphical background to be displayed in your game.

Sound effects should be PCM files. These can be loaded a couple of ways.

Controls / Gamepads

You can use the console gamepad for your Blu-Play game, but not all buttons can be used - and only one gamepad is supported. That means 2-player games are sadly out of the question.

You can also connect a USB keyboard to your console - but these only lets you press one button at a time, so it's not useful for all types of games.

Limitations

When creating a BD-J game, you're obviously going to have limitations compared to creating native games. That goes without saying. Apart from not having modern graphics APIs available, your game also won't run as fast as a native game. And to top it off, the max filesize for your JAR file is only 4 mb. Luckily you can store your assets outside the JAR though.

Build tools

It is actually rather simple to compile a Blu-ray Disc Java Xlet. All you need is the BDJ.jar file to compile against, and then tell javac to compile with source 1.3 and target 1.3

To follow proper protocol though, you are supposed to find quite a few stub files from different vendors. Then assemble them in order to generate the BDJ.jar file.

But since some of the stub files are no where to be found today, we can't follow proper protocol. (All online guides you can find are outdated). Luckily you can find the BDJ.jar file elsewhere nowadays, such as in the minimal SDK, and also in certain software media players such as PowerDVD.

And then it's just a question of adding this BDJ.jar to your classpath before compiling. Example:

javac -source 1.3 -target 1.3 -cp path/to/bdj.jar path/to/sourcefiles/*.java

You won't have a BD-J javadoc available this way, but you can use the standard Java 1.3 javadoc for the most part. The few BD-J specific calls you need to make in your game, can be looked up in source codes of other BD-J projects.

Test tools

For testing you can use software media players like PowerDVD or VLC. Simply open the Blu-ray folder or ISO file.

You can add the following command to your IDE to call one of these after compiling:

# For Windows:
"C:\path\to\PowerDVD.exe" AUTOPLAY BD path\to\disc\folder\
"C:\path\to\vlc.exe" bluray:///path\to\disc\folder\ --bluray-menu --fullscreen

# For Linux:
vlc "bluray:///path/to/disc/folder" --bluray-menu --fullscreen

Signing

It is not necessary to sign your Xlet for a simple game. In fact, signing is only necessary when/if you want to

In short, this means you don't have to worry about signing at all at first. It is something you can look into later - if needed. Your game will run fine without signing it.

Hello World

Here's a short simple "Hello World" example.


package com.bluplay.helloworld;

public class HelloWorld extends java.awt.Container implements javax.tv.xlet.Xlet {

  private org.havi.ui.HScene scene;
  private java.awt.Font font;

  public void initXlet(javax.tv.xlet.XletContext context) {
    setSize(1280, 720);
    scene = org.havi.ui.HSceneFactory.getInstance().getDefaultHScene();
    scene.add(this);
    scene.validate();
  }

  public void startXlet() {
    setVisible(true);
    scene.setVisible(true);
    repaint();
  }

  public void pauseXlet() {
    setVisible(false);
  }

  public void destroyXlet(boolean unconditional) {
    scene.remove(this);
    scene = null;
  }

  public void paint(java.awt.Graphics g) {
    g.setColor(new java.awt.Color(0x000000));
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(new java.awt.Color(0xffffff));
    if (font == null) {
      font = new java.awt.Font(null, java.awt.Font.PLAIN, 30);
      g.setFont(font);
    }
    g.drawString("Hello World!", 50, 50);
  }
}