public abstract class WorldGame extends Object implements Updatable, Renderable
MapTile
,
Handler
, Factory
...).
It contains different elements, such as:
Config
: 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
It has to be handled by a 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 public void load() { // Load resources here world.loadFromFile(Media.get("level.lvl")); } @Override public void update(double extrp) { // Update routine world.update(extrp); } @Override public 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 Resolution |
output
External display reference.
|
protected Resolution |
source
Internal display reference.
|
protected int |
width
Screen size width.
|
Constructor and Description |
---|
WorldGame(Config config)
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. |
void |
saveToFile(Media media)
Save world to the specified file.
|
protected abstract void |
saving(FileWriting file)
Internal world saves; called from
saveToFile(Media) function. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
render
protected final Config config
protected final Resolution source
protected final Resolution output
protected final int width
protected final int height
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
MapTile.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
MapTile.load(FileReading)
...file
- The file reader reference.IOException
- If error on reading.public final void saveToFile(Media media)
media
- The output media.LionEngineException
- If error on saving to file.public final void loadFromFile(Media media)
media
- The input media.LionEngineException
- If error on loading from file.Copyright © 2016 Byron 3D Games Studio. All rights reserved.