com.b3dgs.lionengine.game
Class AbstractWorld

java.lang.Object
  extended by com.b3dgs.lionengine.game.AbstractWorld

public abstract class AbstractWorld
extends java.lang.Object

Default world model, designed to contain game elements (map, player, entitys...). This model already handle support of filtering, intermediate buffer, and useful tools.


Field Summary
 float factX
          Screen factor (horizontal-vertical); difference between current/ref width-height.
 float factY
          Screen factor (horizontal-vertical); difference between current/ref width-height.
 int height
          Screen size (width-height).
 Initializer init
          Initializer reference.
protected  int mapViewH
          Represents the number of visible horizontal-vertical tiles.
protected  int mapViewV
          Represents the number of visible horizontal-vertical tiles.
 Screen screen
          Screen reference.
 int width
          Screen size (width-height).
 
Constructor Summary
AbstractWorld(Screen screen)
          Create a new world.
 
Method Summary
 void calculateMapView(TileBasedMap<?> map)
          Need to be called when the map is built, in order to know its visibility on screen.
 void calculateMapView(TileBasedMap<?> map, AbstractControlPanel<?,?,?> panel)
          Calculate map view from a control panel (mainly for strategy game).
 int getHorizontalMapView()
          Get the number of horizontal viewable map tiles.
 int getVerticalMapView()
          Get the number of vertical viewable map tiles.
protected abstract  void load(FileReader file)
          Internal world loads.
protected abstract  void load(XMLNode world)
          Internal world loads.
 void loadFromFile(java.lang.String filename)
          Load world from the specified file.
 void loadFromXML(java.lang.String filename)
          Load world from the specified file in XML.
protected abstract  void render(java.awt.Graphics2D g)
          Internal world rendering.
protected abstract  void save(FileWriter file)
          Internal world saves.
protected abstract  void save(XMLNode world)
          Internal world saves.
 void saveToFile(java.lang.String filename)
          Save world to the specified file.
 void saveToXML(java.lang.String filename)
          Save world to the specified file using XML.
abstract  void update(Keyboard keyboard, Mouse mouse, float extrp)
          Update world, and input calls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

screen

public final Screen screen
Screen reference.


init

public final Initializer init
Initializer reference.


width

public final int width
Screen size (width-height).


height

public final int height
Screen size (width-height).


factX

public final float factX
Screen factor (horizontal-vertical); difference between current/ref width-height.


factY

public final float factY
Screen factor (horizontal-vertical); difference between current/ref width-height.


mapViewH

protected int mapViewH
Represents the number of visible horizontal-vertical tiles.


mapViewV

protected int mapViewV
Represents the number of visible horizontal-vertical tiles.

Constructor Detail

AbstractWorld

public AbstractWorld(Screen screen)
Create a new world.

Parameters:
screen - screen reference.
Method Detail

calculateMapView

public void calculateMapView(TileBasedMap<?> map)
Need to be called when the map is built, in order to know its visibility on screen.

Parameters:
map - map reference.

calculateMapView

public void calculateMapView(TileBasedMap<?> map,
                             AbstractControlPanel<?,?,?> panel)
Calculate map view from a control panel (mainly for strategy game).

Parameters:
map - map reference.
panel - control panel reference.

getHorizontalMapView

public int getHorizontalMapView()
Get the number of horizontal viewable map tiles.

Returns:
number of horizontal viewable map tiles.

getVerticalMapView

public int getVerticalMapView()
Get the number of vertical viewable map tiles.

Returns:
number of vertical viewable map tiles.

update

public abstract void update(Keyboard keyboard,
                            Mouse mouse,
                            float extrp)
Update world, and input calls.

Parameters:
keyboard - keyboard reference.
mouse - mouse reference.
extrp - extrapolation value.

render

protected abstract void render(java.awt.Graphics2D g)
Internal world rendering.

Parameters:
g - graphic output.

save

protected abstract void save(FileWriter file)
                      throws java.io.IOException
Internal world saves.

Parameters:
file - file writer reference.
Throws:
java.io.IOException - error on writing.

load

protected abstract void load(FileReader file)
                      throws java.io.IOException
Internal world loads.

Parameters:
file - file reader reference.
Throws:
java.io.IOException - error on reading.

save

protected abstract void save(XMLNode world)
Internal world saves.

Parameters:
world - node reference.

load

protected abstract void load(XMLNode world)
Internal world loads.

Parameters:
world - node reference.

saveToFile

public final void saveToFile(java.lang.String filename)
Save world to the specified file.

Parameters:
filename - output file.

saveToXML

public final void saveToXML(java.lang.String filename)
Save world to the specified file using XML.

Parameters:
filename - output file.

loadFromFile

public final void loadFromFile(java.lang.String filename)
Load world from the specified file.

Parameters:
filename - input file.

loadFromXML

public final void loadFromXML(java.lang.String filename)
Load world from the specified file in XML.

Parameters:
filename - input file.