public abstract class WorldGame extends Object
MapTile
, HandlerEntityGame
,
FactoryObjectGame
...).
It contains different elements, such as:
Keyboard
: The keyboard input reference, in order to retrieve keyboard key usesMouse
: The mouse input reference, in order to retrieve mouse movement and click usesConfig
: The configuration used by the Loader
width
: The source screen width, retrieve from the source screen Resolution
height
: The source screen height, retrieve from the source screen Resolution
Sequence
.
Here a standard world usage:
public class MySequence extends Sequence { private final World world; public MySequence(Loader loader) { super(loader); // Initialize variables here world = new World(this); } @Override protected void load() { // Load resources here world.loadFromFile(Media.get("level.lvl")); } @Override protected void update(double extrp) { // Update routine world.update(extrp); } @Override protected void render(Graphic g) { // Render routine world.render(g); } }
Modifier and Type | Field and Description |
---|---|
protected Config |
config
Config reference.
|
protected int |
height
Screen size height.
|
protected Keyboard |
keyboard
Keyboard reference.
|
protected Mouse |
mouse
Mouse reference.
|
protected Resolution |
output
External display reference.
|
protected Resolution |
source
Internal display reference.
|
protected int |
width
Screen size width.
|
Constructor and Description |
---|
WorldGame(Sequence sequence)
Create a new world.
|
Modifier and Type | Method and Description |
---|---|
void |
loadFromFile(Media media)
Load world from the specified file.
|
protected abstract void |
loading(FileReading file)
Internal world loads; called from
loadFromFile(Media) function. |
abstract void |
render(Graphic g)
Internal world rendering.
|
void |
saveToFile(Media media)
Save world to the specified file.
|
protected abstract void |
saving(FileWriting file)
Internal world saves; called from
saveToFile(Media) function. |
abstract void |
update(double extrp)
Internal world updates.
|
protected final Keyboard keyboard
protected final Mouse mouse
protected final Config config
protected final Resolution source
protected final Resolution output
protected final int width
protected final int height
public abstract void update(double extrp)
extrp
- The extrapolation value.public abstract void render(Graphic g)
g
- The graphic output.protected abstract void saving(FileWriting file) throws IOException
saveToFile(Media)
function. The world will be saved in a file
as binary. Here should be called all saving functions, such as MapTileGame.save(FileWriting)
...file
- The file writer reference.IOException
- If error on writing.protected abstract void loading(FileReading file) throws IOException
loadFromFile(Media)
function. The world will be loaded from
an existing binary file. Here should be called all loading functions, such as
MapTileGame.load(FileReading)
...file
- The file reader reference.IOException
- If error on reading.public final void saveToFile(Media media)
media
- The output media.public final void loadFromFile(Media media)
media
- The input media.Copyright © 2014 Byron 3D Games Studio. All rights reserved.