# ScalableGame (Slick - The 2D Library)
Date: 2013-06-03

## org.newdawn.slick
Class ScalableGame

    java.lang.Object
      org.newdawn.slick.ScalableGame

All Implemented Interfaces:
  Game

    public class ScalableGame

extends java.lang.Object
implements Game

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

Author:
  kevin

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

### ScalableGame

    public ScalableGame(Game held,
                        int normalWidth,
                        int normalHeight)

  Create a new scalable game wrapper

  Parameters:
    `held` - The game to be wrapper and displayed at a different resolution
    `normalWidth` - The normal width of the game
    `normalHeight` - The noral height of the game

### ScalableGame

    public ScalableGame(Game held,
                        int normalWidth,
                        int normalHeight,
                        boolean maintainAspect)

  Create a new scalable game wrapper

  Parameters:
    `held` - The game to be wrapper and displayed at a different resolution
    `normalWidth` - The normal width of the game
    `normalHeight` - The noral height of the game
    `maintainAspect` - True if we should maintain the aspect ratio

Method Detail

### init

    public void init(GameContainer container)
              throws SlickException

  Description copied from interface: `Game`
  Initialise the game. This can be used to load static resources. It's called before the game loop starts

  Specified by:
    `init` in interface `Game`
  Parameters:
    `container` - The container holding the game
  Throws:
    `SlickException` - Throw to indicate an internal error
  See Also:
    `BasicGame.init(org.newdawn.slick.GameContainer)`

### recalculateScale

    public void recalculateScale()
                          throws SlickException

  Recalculate the scale of the game

  Throws:
    `SlickException` - Indicates a failure to reinit the game

### update

    public void update(GameContainer container,
                       int delta)
                throws SlickException

  Description copied from interface: `Game`
  Update the game logic here. No rendering should take place in this method though it won't do any harm.

  Specified by:
    `update` in interface `Game`
  Parameters:
    `container` - The container holing this game
    `delta` - The amount of time thats passed since last update in milliseconds
  Throws:
    `SlickException` - Throw to indicate an internal error
  See Also:
    `BasicGame.update(org.newdawn.slick.GameContainer, int)`

### render

    public final void render(GameContainer container,
                             Graphics g)
                      throws SlickException

  Description copied from interface: `Game`
  Render the game's screen here.

  Specified by:
    `render` in interface `Game`
  Parameters:
    `container` - The container holing this game
    `g` - The graphics context that can be used to render. However, normal rendering routines can also be used.
  Throws:
    `SlickException` - Throw to indicate a internal error
  See Also:
    `Game.render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)`

### renderOverlay

    protected void renderOverlay(GameContainer container,
                                 Graphics g)

  Render the overlay that will sit over the scaled screen

  Parameters:
    `container` - The container holding the game being render
    `g` - Graphics context on which to render

### closeRequested

    public boolean closeRequested()

  Description copied from interface: `Game`
  Notification that a game close has been requested

  Specified by:
    `closeRequested` in interface `Game`
  Returns:
    True if the game should close
  See Also:
    `Game.closeRequested()`

### getTitle

    public java.lang.String getTitle()

  Description copied from interface: `Game`
  Get the title of this game

  Specified by:
    `getTitle` in interface `Game`
  Returns:
    The title of the game
  See Also:
    `Game.getTitle()`

Copyright © 2006 New Dawn Software. All Rights Reserved.