Game Development Reference
In-Depth Information
This is in keeping with our objective of optimizing both memory and CPU cycles,
so that these are available for the more advanced parts of our game play, such as the
game play logic, collision detection, or physics calculation.
We also added constants that will allow us to later scale this 640 by 400 game pro-
totype to fit display screens of different resolutions such as Pseudo HD (1280 by 720),
True HD (1920 by 1080), and UHD (4096 by 2160). These can also be used in the
game logic, to calculate the size of the screen area to determine movement boundaries.
So far, we have added our actor and supporting cast engine, as well as our basic
event handling processing, so that we can start to determine how this InvinciBagel
game hero is going to move around on the screen in the next chapter. We have .handle()
as well as .update() and .collide() methods in place to hold the code, which will anim-
ate a character, and eventually enemies, in both the single-player as well as a future
multi-player version of this game.
Next, let's revisit our overview diagram of this game design, and take a look at the
InvinciBagel package, the InvinciBagel.java class, and the GamePlayLoop and Actor
and Hero classes, which provide the foundation for our game play processing and actor
(and projectiles, treasure, enemy and obstacles or “props”) creation.
Updating Our Game Design: Adding
Event Handling
Let's update the diagram that I introduced in Chapter 7 (Figure 7-19) and updated in
Chapter 8 (Figure 8-17) to include the ActionEvent and KeyEvent handling by the
EventHandler class. As you can see in Figure 9-15 , I added the EventHandler event
handling class to the diagram as well as the ActionEvent objects that handle our UI
design control and the KeyEvent that we are going to use to move the InvinciBagel act-
or around the screen. Since the .setOnKeyPressed() and .setOnKeyReleased() methods
are called off of the scene Scene object named scene, and the ActionEvent is also con-
tained under the Scene object, I placed these inside of the Scene object in the diagram.
 
Search WWH ::




Custom Search