inventory, health points, and so on, but the structure of each player would
be the same.
That is, every player object would have the same collection of variables (name,
health, location, and so on) and the same functions that you'd want to run
(set this player's health, teleport the player to a new location, that sort of
thing). That's where objects come in. You'd create an object in Java to repre-
sent each player in the system. You'd write code to do things to a player, and
that code would work no matter which specific player you were using at the
time. That's exactly what the Minecraft folks did. Here's how the magic works.
In Java, you can define a pile of variables and a bunch of code that uses those
variables, sort of like defining a recipe. You can then create and use an object
that's built from that recipe. Java calls this kind of recipe a class . From that
class recipe, Java will make running objects. Look at the following figure;
here you have a few variables and some functions for a sample Player class,
and some objects it can make.
It's just like building objects from Lego blocks: the blocks may all be the same,
but when you follow the printed instructions that come with the kit, you can
build a spaceship.