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

Defining Sprites

Sprite3D is the superclass for the local sprite class, TourSprite, and the distributed sprite class, DistTourSprite. Figure 32-4 shows the class hierarchy and all its public methods.

TourSprite and DistTourSprite offer a simplified interface for Sprite3D, setting the sprite's rate of movement and rotation increment. TourSprite contains networking code to send its details to the server.

The version of Sprite3D in NetTour3D is similar to the one in Tour3D. The main differences are in the subgraph created for a sprite, which looks like Figure 32-5.

The subgraph has a BranchGroup node at its top (objectBG), with capabilities set to make the branch detachable. This permits the sprite to be removed from the scene when the sprite's client leaves the world.

The other change is the addition of an OrientedShape3D shape holding the client's name and being set to rotate around the y-axis to follow the client's viewpoint. The shape is added to the TransformGroup above the Switch node, which means that the sprite's name will remain on the screen if it is made inactive (invisible). The idea is that the sprite is unavailable but still present in the world.

The sprite classes

Figure 32-4. The sprite classes

The subgraph for the Sprite3D sprite

Figure 32-5. The subgraph for the Sprite3D sprite

The subgraph for the 3D model, together with its adjustments ...

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