Game Development Reference
In-Depth Information
directionFacing = direction ;
movementType = movement ;
currentlyMoving = false;
}
I bolded the variables in the parameter list, as well as where they are used inside the
constructor method, to set the states (variables) for the object. These variables are de-
clared at the top of the GamePiece class, which you have used to design, define, and
create the GamePiece object. This second constructor method can be said to overload
the first constructor method, because it uses the exact same method call (method
name), with a different parameter list (full of parameters, versus empty or no paramet-
ers). This gives you the default object constructor method as well as a custom object
constructor method, so in your game logic, you can create a default GamePiece or a
custom GamePiece.
Summary
In this third chapter you took a look at some of the more important concepts and struc-
tures found in the Java 8 programming language. Certainly, I cannot cover everything
in Java in one chapter, so I stuck with concepts, constructs, and keywords that you will
be using to create a game over the course of this topic. Most Java topics are 800 pages
or more, so if you want to get really deep into Java, I suggest Beginning Java 8 Funda-
mentals by Kishori Sharan (Apress, 2014).
You started by taking a high-level view of Java, considering its syntax, including
Java comments and delimiters , APIs, and the Java packages that a Java API contains.
You also studied Java classes , including nested classes and inner classes, as the Java
packages contain Java classes. You then went the next level down in Java, to the meth-
od , which is like the function in other programming languages, as well as to a special
kind of Java method called a constructor method.
Next, you explored how Java represents data, using fields, or data fields, examining
the different types, such as constants, or fixed data fields, and variables, or data fields
that can change their values. After that, you took a closer look at Java modifier
keywords , including the public , private , and protected access control keywords and
the final , static , abstract , volatile , and synchronized nonaccess control modifier
keywords.
After finishing with the basic code structures and how to modify them, you moved
on to the primary Java data types, such as boolean , char , byte , int , float , short , long ,
Search WWH ::




Custom Search