
413Chapter Review
if(active)
setVisible(true);
else
setVisible(false);
setX(ts.X);
setY(ts.Y);
setVelocity(ts.velocity);
}
Listing 12.29. Updating a client torpedo with data sent from the server.
12.14.3 Modifications to the Game Class
e Game class run function includes a call to the communicate function just as the server
code did (Listing 12.30).
// update(), ai(), collisions() and render() are pure virtual functions
// You must override these functions in your code when you inherit from
// game.h
if (!paused) // If not paused
{
update(); // Update all game items
ai(); // Artificial intelligence
collisions(); // Handle collisions
input->vibrateControllers(frameTime); ...