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

Chapter 18. 3D Sprites

In this chapter, I'll develop a Sprite3D class, which can be subclassed to create different kinds of sprites. The user's sprite (a robot) and a chasing sprite (a hand) are shown in action in Figure 18-1 sharing the checkerboard with some scenery (a palm tree and castle) and obstacles (the red poles).

3D sprites in action

Figure 18-1. 3D sprites in action

Features illustrated by the Tour3D application include:

Sprite behavior

The sprites are controlled by Behavior subclasses.

A third-person camera

A simple third-person camera automatically adjusts the user's viewpoint as the user's sprite moves around the scene. The camera can be zoomed in and out by keyboard controls.

Obstacles

The scene contains obstacles that a sprite can't pass through. (They're represented by cylinders in Figure 18-1.) Sprites are prevented from moving off the checkered floor.

Collision detection

Collision detection between a sprite and the obstacles is implemented by bounds checking.

Scenery configuration

A "tour" text file loaded at start time contains obstacle and scenery information. The scenery models (e.g., the castle and the palm tree in this example) are loaded with PropManager objects.

A background image

The scene's background is drawn using a scaled JPEG.

Full-screen display

The application is configured to be full-screen.

Class Diagrams for Tour3D

Figure 18-2 shows class diagrams for Tour3D. Only class ...

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