Class GameBase
java.lang.Object
GameBase
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
Gameplay
Main class of game.
Responsibility: main loop, game objects and window.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addKeyListener(KeyListener listener)
Add new key listener.protected void
Scene awake on open the game.void
destroy(GameObject gameObject)
Destroy gameobject and invoke OnDestroy().void
finish()
Stop and finish main loop.protected float
DeltaTime of current frame.Get gameobjects in gameplay.void
initialize(GameObject gameObject)
Initialize gameobject on gameplay.protected void
Destroy scene after game objects.protected void
openWindow(int widthOfWindow, int heightOfWindow, String title)
protected void
Render scenes before game objects.void
run()
Main loop of game.protected void
Invoke before main loop.protected void
Update scene before game objects.
-
Field Details
-
DEFAULT_WIDTH_OF_WINDOW
public static final int DEFAULT_WIDTH_OF_WINDOW- See Also:
- Constant Field Values
-
DEFAULT_HEIGHT_OF_WINDOW
public static final int DEFAULT_HEIGHT_OF_WINDOW- See Also:
- Constant Field Values
-
DESIRED_FPS
public final long DESIRED_FPS- See Also:
- Constant Field Values
-
DESIRED_DELTA_LOOP
public final long DESIRED_DELTA_LOOP- See Also:
- Constant Field Values
-
frame
-
-
Constructor Details
-
GameBase
public GameBase()Awake of game.
-
-
Method Details
-
initialize
Initialize gameobject on gameplay. -
destroy
Destroy gameobject and invoke OnDestroy(). -
addKeyListener
Add new key listener.- Parameters:
listener
- - new key listener.
-
run
public void run()Main loop of game. -
finish
public void finish()Stop and finish main loop. -
getGameObjects
Get gameobjects in gameplay. -
getDeltaTime
protected float getDeltaTime()DeltaTime of current frame. -
openWindow
- Parameters:
widthOfWindow
-heightOfWindow
-title
-
-
awakeScene
protected void awakeScene()Scene awake on open the game. -
startScene
protected void startScene()Invoke before main loop. -
updateScene
protected void updateScene()Update scene before game objects. -
onDestroyScene
protected void onDestroyScene()Destroy scene after game objects. -
renderScene
Render scenes before game objects.- Parameters:
g
- - Graphics2D
-