Game Development Reference
In-Depth Information
movementType = movement;
}
The convention is to create .get() and .set() methods, as is done here. These allow
your Java code to easily access your object states (variables). Now, it is time to install
all these attributes (constants), states (variables), and behaviors (methods) into a blue-
print for your object. As mentioned earlier, this is done using the Java class program-
ming structure.
Creating an InvinciBagel Blueprint: Create the
GamePiece Class
Let's install all this InvinciBagel virtualization code into a GamePiece class to create a
class and constructor method that is intended for game-piece objects:
public class GamePiece
private static final String FLAVOR_OF_BAGEL
= "Pumpernickel"; // Flavor (or type) of bagel
private static final String SIZE_OF_BAGEL = "Mini
Bagel";
// Size (classification) of bagel
public int invinciBagelX = 0;
//
X screen location of the InvinciBagel
public int invinciBagelY = 0;
// Y
screen location of the InvinciBagel
public String bagelOrientation = "side";
// Define bagel orientation (front, side, top)
public int lifeIndex = 1000;
//
Defines units of lifespan used
public int hitsIndex
= 0;
//
Defines units of damage
(hits taken)
public String directionFacing
= "E";
// Direction that the bagel object is
facing
public String movementType = "idle";
//
Type of
Search WWH ::




Custom Search