Game Development Reference
In-Depth Information
= "E"; // Direction that the object is facing
public String movementType = "idle"
// Type of
movement (idle, fly, run, jump)
public boolean currentlyMoving = false;
//
Flag
showing if the object is in motion
As you progress through this topic and create the InvinciBagel game, you will be
adding attributes, states, and behaviors that will make the InvinciBagel, as well as its
game environment and game play, more realistic, fun, and exciting, just as you would
do in real life. In fact, you are using Java objects and Java constructs to model, a real-
istic virtual world in which InvinciBagel players can triumph over evil and shoot cream
cheese balls at delicious targets.
Let's look at a couple of the methods that you might develop to control the Invin-
ciBagel behavior. You will be creating complex methods over the course of this topic to
accomplish game play objectives, so I am just going to give you an idea here of how
methods provide behaviors to objects for the purpose of demonstrating how objects can
be created that reflect how real-world objects function.
For your game play of the InvinciBagel, the main behaviors will be 2D movement
around the screen, relative to the x (width) and y ( height) dimension, which will access,
use, and update the integer invinciBagelX , invinciBagelY , and the boolean cur-
rentlyMoving data fields discussed previously; the InvinciBagel character's orienta-
tion (front facing, sideways, facing down, and so on), which will access, use, and up-
date the bagelOrientation String field; the life expectancy of the InvinciBagel, which
will access, use, and update the lifeIndex variable; the health of the InvinciBagel,
which will access, use, and update the hitsIndex variable; the direction (East or West)
in which the InvinciBagel is traveling, which will access, use, and update the direc-
tionFacing String variable; and the type of movement (flying, jumping, running, idle)
that the InvinciBagel is using , which will access, use, and update the movementType
String variable.
Here is how you declare these methods (behaviors) and pseudocode regarding what
they are going to do:
public void moveInvinciBagel(int x, int y) {
currentlyMoving = true;
invinciBagelX = x;
invinciBagelY = y;
}
Search WWH ::




Custom Search