|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.ScalableGame
public class ScalableGame
A wrapper to allow any game to be scalable. This relies on knowing the normal width/height of the game - i.e. the dimensions that the game is expecting to be run at. The wrapper then takes the size of the container and scales rendering and input based on the ratio. Note: Using OpenGL directly within a ScalableGame can break it
Constructor Summary | |
---|---|
ScalableGame(Game held,
int normalWidth,
int normalHeight)
Create a new scalable game wrapper |
|
ScalableGame(Game held,
int normalWidth,
int normalHeight,
boolean maintainAspect)
Create a new scalable game wrapper |
Method Summary | |
---|---|
boolean |
closeRequested()
Notification that a game close has been requested |
java.lang.String |
getTitle()
Get the title of this game |
void |
init(GameContainer container)
Initialise the game. |
void |
recalculateScale()
Recalculate the scale of the game |
void |
render(GameContainer container,
Graphics g)
Render the game's screen here. |
protected void |
renderOverlay(GameContainer container,
Graphics g)
Render the overlay that will sit over the scaled screen |
void |
update(GameContainer container,
int delta)
Update the game logic here. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScalableGame(Game held, int normalWidth, int normalHeight)
held
- The game to be wrapper and displayed at a different resolutionnormalWidth
- The normal width of the gamenormalHeight
- The noral height of the gamepublic ScalableGame(Game held, int normalWidth, int normalHeight, boolean maintainAspect)
held
- The game to be wrapper and displayed at a different resolutionnormalWidth
- The normal width of the gamenormalHeight
- The noral height of the gamemaintainAspect
- True if we should maintain the aspect ratioMethod Detail |
---|
public void init(GameContainer container) throws SlickException
Game
init
in interface Game
container
- The container holding the game
SlickException
- Throw to indicate an internal errorBasicGame.init(org.newdawn.slick.GameContainer)
public void recalculateScale() throws SlickException
SlickException
- Indicates a failure to reinit the gamepublic void update(GameContainer container, int delta) throws SlickException
Game
update
in interface Game
container
- The container holing this gamedelta
- The amount of time thats passed since last update in milliseconds
SlickException
- Throw to indicate an internal errorBasicGame.update(org.newdawn.slick.GameContainer, int)
public final void render(GameContainer container, Graphics g) throws SlickException
Game
render
in interface Game
container
- The container holing this gameg
- The graphics context that can be used to render. However, normal rendering
routines can also be used.
SlickException
- Throw to indicate a internal errorGame.render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
protected void renderOverlay(GameContainer container, Graphics g)
container
- The container holding the game being renderg
- Graphics context on which to renderpublic boolean closeRequested()
Game
closeRequested
in interface Game
Game.closeRequested()
public java.lang.String getTitle()
Game
getTitle
in interface Game
Game.getTitle()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |