Game Development Reference
In-Depth Information
Let's take a look at the various game design components that we you will need to un-
derstand to be able to build a game, as well as what Java 8 (or JavaFX) packages and
classes you can use to implement these aspects of game play, which I like to term com-
ponents of game play. These can include the game play elements themselves (com-
monly referred to as sprites ) as well as processing engines, which you will either code
yourself, or import preexisting Java code libraries for, such as physics simulation and
collision detection .
Sprites are the foundation of game play, defining your main character , projectiles
used to damage this main character, and the enemies firing these projectiles. Sprites are
2D graphics elements and can be either static (fixed, a single image) or dynamic (an-
imated, a seamless loop of several images). A sprite will be moved around the screen
based on programming logic, which dictates how the game is to function. Sprites need
to be composited with background imagery and other game elements as well as other
sprites and so the graphics used to create the sprites will need to support transparent
backgrounds .
In Chapter 4 , I introduced you to the concept of alpha channels and transparency.
You will need to achieve this same end result with your sprites to create a seamless
visual experience with your game. The next most important aspect of game play is col-
lision detection , because if your sprites simply flew right past each other on the screen
and never did anything cool when they touched, or “intersected” each other, then you
really would not have much of a game! Once you add a collision detection engine
(composed of intersection logic processing routines) your game can ascertain when
any two sprites are touching (edges) or overlapping each other. A collision detection
will call (trigger) other logic processing routines that will determine what happens
when any two given sprites, such as a projectile and the main character, intersect. For
example, when a projectile intersects the main character, damage points might accrue,
life force index might be decreased, or a death animation may be started. In contrast, if
a treasure item intersects with (is picked up by) the main character, power or capability
points might accrue, the life force index might be increased, or an “I found it” jubila-
tion animation might be started. As you can see, the collision detection for your game
is one of the foundational design elements of your game play, besides the sprites (char-
acters, projectiles, treasures, enemies, obstacles, and so on) themselves, which is why I
am covering this concept early on in the topic.
The concept next in significance to your game play is real-world physics simula-
tion . The addition of things like gravity; friction; bounce; drag; acceleration; motion
curves, such as the JavaFX Interpolator class provides; and the like add an additional
level of realism on top of the already photo-realistic sprites, synchronized animation
sequences, scenic backgrounds, and highly accurate collision detection.
Search WWH ::




Custom Search