O'Reilly logo

Killer Game Programming in Java by Andrew Davison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 32. A Networked Virtual Environment

This chapter utilizes the threaded client/server model, which first appeared in the multiplayer chat system in Chapter 30 and now appears in the service of a networked virtual environment (NVE).

When clients connect to the server, they appear as a 3D sprite in a shared world filled with sprites representing other users. The scenery is the familiar checkerboard seen in many of the earlier Java 3D examples, along with a castle and some red poles. Users can move their sprites around the world but cannot pass through the poles.

Figure 32-1 shows the NetTour3D application being run by two clients. Each window is the clients' view of the shared world, represented by a third-person camera that follows the clients' sprite as it moves. All the visitors use the same robot image, but each user's name floats above their robot.

Two visitors to the NetTour3D world

Figure 32-1. Two visitors to the NetTour3D world

Key features demonstrated include:

Local and distributed sprites

Each user is represented by two kinds of sprites: a local sprite on the users' machine, and distributed sprites present on every other machine. When users moves their local sprites, the distributed sprites are updated as well via messages sent from the client, through the server, and finally to the other clients. The local and distributed sprites are subclasses of a Sprite3D class, so they share a great deal of functionality. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required