public class Game extends java.lang.Object implements java.lang.Runnable, Subject<InputEvent>
Modifier and Type | Field and Description |
---|---|
android.content.Context |
context |
java.lang.String |
log |
int |
normalItemCount |
int |
rainyAttackCount |
int |
rainyItemCount |
int |
snowyAttackCount |
int |
snowyItemCount |
int |
sunnyAttackCount |
int |
sunnyItemCount |
int |
UIHeight |
Constructor and Description |
---|
Game(android.content.Context context,
int width,
int height,
WeatherStatus status,
boolean graphicsRenderer)
initialises a new game
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(Observer<InputEvent> observer) |
GameWorld |
getGameWorld() |
int |
getHeight() |
static Game |
getInstance() |
android.view.SurfaceView |
getView() |
int |
getWidth() |
boolean |
isRunning() |
void |
notify(InputEvent event)
notifies all the games' observers about an input event
|
void |
onInputEvent(InputEvent event) |
void |
pause()
called when the activity is paused
saves the important data to the database and joines the games thread
|
void |
removeObserver(Observer<InputEvent> observer) |
void |
resume()
called when the game is resumed
creates a new game thread and starts it
|
void |
run()
contains the game loop
updates and renders the world as long as the game is running
|
void |
setRunning(boolean running) |
public android.content.Context context
public int UIHeight
public java.lang.String log
public int normalItemCount
public int sunnyItemCount
public int snowyItemCount
public int rainyItemCount
public int sunnyAttackCount
public int rainyAttackCount
public int snowyAttackCount
public Game(android.content.Context context, int width, int height, WeatherStatus status, boolean graphicsRenderer)
context
- the games context, eg. the games activitywidth
- the with of the devices displayheight
- the height of the devices displaystatus
- the weather status of the gamegraphicsRenderer
- indicates which graphics mode should be usedpublic void run()
run
in interface java.lang.Runnable
public void pause()
public void resume()
public android.view.SurfaceView getView()
public void setRunning(boolean running)
public int getWidth()
public int getHeight()
public static Game getInstance()
public GameWorld getGameWorld()
public void onInputEvent(InputEvent event)
public void addObserver(Observer<InputEvent> observer)
addObserver
in interface Subject<InputEvent>
public void removeObserver(Observer<InputEvent> observer)
removeObserver
in interface Subject<InputEvent>
public void notify(InputEvent event)
notify
in interface Subject<InputEvent>
event
- the users inputpublic boolean isRunning()