Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epoxy
GitHub Repository: epoxy/proj11
Path: blob/master/SLICK_HOME/src/org/newdawn/slick/state/GameState.java
1457 views
1
package org.newdawn.slick.state;
2
3
import org.newdawn.slick.GameContainer;
4
import org.newdawn.slick.Graphics;
5
import org.newdawn.slick.InputListener;
6
import org.newdawn.slick.SlickException;
7
8
/**
9
* A single state building up part of the game. The state include rendering, logic and input handling
10
* for the state.
11
*
12
* @author kevin
13
*/
14
public interface GameState extends InputListener {
15
/**
16
* Get the ID of this state
17
*
18
* @return The game unique ID of this state
19
*/
20
public int getID();
21
22
/**
23
* Initialise the state. It should load any resources it needs at this stage
24
*
25
* @param container The container holding the game
26
* @param game The game holding this state
27
* @throws SlickException Indicates a failure to initialise a resource for this state
28
*/
29
public void init(GameContainer container, StateBasedGame game) throws SlickException;
30
31
/**
32
* Render this state to the game's graphics context
33
*
34
* @param container The container holding the game
35
* @param game The game holding this state
36
* @param g The graphics context to render to
37
* @throws SlickException Indicates a failure to render an artifact
38
*/
39
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException;
40
41
/**
42
* Update the state's logic based on the amount of time thats passed
43
*
44
* @param container The container holding the game
45
* @param game The game holding this state
46
* @param delta The amount of time thats passed in millisecond since last update
47
* @throws SlickException Indicates an internal error that will be reported through the
48
* standard framework mechanism
49
*/
50
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException ;
51
52
/**
53
* Notification that we've entered this game state
54
*
55
* @param container The container holding the game
56
* @param game The game holding this state
57
* @throws SlickException Indicates an internal error that will be reported through the
58
* standard framework mechanism
59
*/
60
public void enter(GameContainer container, StateBasedGame game) throws SlickException;
61
62
/**
63
* Notification that we're leaving this game state
64
*
65
* @param container The container holding the game
66
* @param game The game holding this state
67
* @throws SlickException Indicates an internal error that will be reported through the
68
* standard framework mechanism
69
*/
70
public void leave(GameContainer container, StateBasedGame game) throws SlickException;
71
}
72
73