Skip to Main Content
Killer Game Programming in Java
book

Killer Game Programming in Java

by Andrew Davison
May 2005
Intermediate to advanced content levelIntermediate to advanced
998 pages
26h
English
O'Reilly Media, Inc.
Content preview from Killer Game Programming in Java

The Bug Starts Running

BugRunner fixes the frame rate to be 40 FPS; anything faster makes it almost impossible to move the ant quickly enough to intercept a dropping ball.

The application's constructor loads and starts the BladeRunner sequence:

    // load the background MIDI sequence
    midisLoader = new MidisLoader();
    midisLoader.load("br", "blade_runner.mid");
    midisLoader.play("br", true);   // repeatedly play it

Since BugRunner plays one sequence at a time, it's loaded directly via a call to load() rather than being specified in a MIDI information file. MidisLoader assumes the sequence is in the Sounds/ subdirectory.

Warning

Using a well-known piece of music, like the BladeRunner theme, is a bad idea for a game intended for widespread distribution. The thorny issue of copyright is bound to come up. I've thrown caution to the wind since BladeRunner is one of my favorite sci-fi movies, and the music is great.

BugRunner sets up window listener methods for pausing and resuming the game in a similar manner to the WormChase application in Chapter 3. windowClosing() is different:

    public void windowClosing(WindowEvent e)
    {  bp.stopGame();
       midisLoader.close();
    }

The call to close() in MidisLoader ensures the sequence is stopped at termination time.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Game Development with LibGDX: From Beginner to Professional

Java Game Development with LibGDX: From Beginner to Professional

Lee Stemkoski

Publisher Resources

ISBN: 0596007302Supplemental ContentErrata Page