public class Game
extends javafx.application.Application
Modifier and Type | Field and Description |
---|---|
(package private) javafx.scene.canvas.Canvas |
canvas
area where game graphics are displayed
|
(package private) javafx.scene.canvas.GraphicsContext |
context
object with methods to draw game entities on canvas
|
double |
deltaTime
amount of time that has passed since the last iteration of the game loop
|
Group |
group
The root collection for all
Entity objects in this game. |
Input |
input
Used to store and update the state of the keyboard and mouse.
|
(package private) long |
previousTime
timestamp for start of previous game loop; used to calculate
deltaTime |
static int |
windowHeight
default height of game canvas.
|
static int |
windowWidth
default width of game canvas.
|
Constructor and Description |
---|
Game() |
Modifier and Type | Method and Description |
---|---|
void |
create()
Initialize objects used in this game.
|
void |
start(javafx.stage.Stage mainStage)
Initializes the window, Input and Group objects,
and manages the life cycle of the game (initialization and game loop).
|
void |
update(double dt)
Update objects used in this game.
|
public static int windowWidth
public static int windowHeight
javafx.scene.canvas.Canvas canvas
javafx.scene.canvas.GraphicsContext context
public Input input
long previousTime
deltaTime
public double deltaTime
public void create()
public void update(double dt)
dt
- amount of time that has passed since the last iteration of the game looppublic void start(javafx.stage.Stage mainStage)
start
in class javafx.application.Application