Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Haakon Gunleiksrud
TDT4240_v20_haakon
Commits
d401db70
Commit
d401db70
authored
Apr 25, 2020
by
Turid Cecilie Dahl
Browse files
#100 Adds comments about game loop & update method and removes interface
parent
e890cdd1
Changes
5
Hide whitespace changes
Inline
Side-by-side
frontend/core/src/com/gameware/game/GameWare.java
View file @
d401db70
...
...
@@ -4,6 +4,7 @@ import com.badlogic.gdx.ApplicationAdapter;
import
com.badlogic.gdx.Gdx
;
import
com.badlogic.gdx.audio.Music
;
import
com.badlogic.gdx.files.FileHandle
;
import
com.badlogic.gdx.graphics.GL20
;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch
;
import
com.badlogic.gdx.utils.Json
;
import
com.badlogic.gdx.utils.JsonReader
;
...
...
@@ -27,9 +28,10 @@ import java.util.Map;
/*
GameWare is the main class, it is the first class to be created. It is called from the AndroidLauncher.
It extends LibGDX's ApplicationAdapter, and the render method delegates to the GameStateManager.
It extends LibGDX's ApplicationAdapter, and the render method (regarded as the game loop)
delegates to the GameStateManager.
Patterns: Singleton, Delegation
Patterns: Singleton, Delegation
, Game Loop
*/
public
class
GameWare
extends
ApplicationAdapter
{
...
...
@@ -89,6 +91,8 @@ public class GameWare extends ApplicationAdapter {
@Override
public
void
render
()
{
// Game loop
// Clearing the screen
Gdx
.
gl
.
glClearColor
(
1
,
1
,
1
,
1
);
Gdx
.
gl
.
glClear
(
GL20
.
GL_COLOR_BUFFER_BIT
);
...
...
frontend/core/src/com/gameware/game/models/ModelInterface.java
View file @
d401db70
...
...
@@ -3,9 +3,8 @@ package com.gameware.game.models;
/*
Data model interface for converting json objects to Java objects
Patterns:
Interface pattern, p
ipe-and-filter
pattern
Patterns:
P
ipe-and-filter
Implementation of the interface from the Interface pattern.
When implemented the class must be a model, in other words a data oriented java object.
Data models used for the filters input/output ports in the QueryIntermediate's pipe-and-filter implementation.
...
...
frontend/core/src/com/gameware/game/sprites/Sprite.java
View file @
d401db70
...
...
@@ -7,7 +7,7 @@ import com.badlogic.gdx.math.Vector3;
Abstract super class/union for game-sprites. Super class instead of interface because of
necessary variables all sprites needs to have
Patterns: Union
Patterns: Union
, Update method
*/
public
abstract
class
Sprite
{
...
...
frontend/core/src/com/gameware/game/states/GameStateManager.java
View file @
d401db70
...
...
@@ -7,7 +7,7 @@ import java.util.Stack;
/*
GameStateManager keeps track of which state is the current one. Delegates to the correct state.
Patterns: State, Delegation
Patterns: State, Delegation
, Update method
*/
public
class
GameStateManager
{
...
...
@@ -40,6 +40,7 @@ public class GameStateManager {
states
.
push
(
state
);
}
// Update method (delegates to current state)
public
void
update
(
float
dt
){
states
.
peek
().
update
(
dt
);
}
...
...
frontend/core/src/com/gameware/game/states/State.java
View file @
d401db70
...
...
@@ -11,9 +11,9 @@ import com.gameware.game.GameWare;
State is the super class/union of all the states in the application.
A state has their own logic and rendering. State contains common variables between
MenuStateUnion and PlayStateUnion.
MenuStateUnion and PlayStateUnion.
All states must have their own update method.
Patterns: State, Union Design
Patterns: State, Union Design
, Update method
*/
public
abstract
class
State
{
...
...
@@ -45,6 +45,7 @@ public abstract class State {
// Abstract state methods
protected
abstract
void
handleInput
();
// Requires all states to have the update method
public
abstract
void
update
(
float
dt
);
public
abstract
void
render
(
SpriteBatch
sb
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment