Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

Scenario Class Reference

Scenario organization. More...

#include <scenario.h>

Collaboration diagram for Scenario:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Scenario ()
 Creates a new scenario. To load a specific map, use loadMap(mapname).
Hit checkPlace (const SDL_Rect &src, const SDL_Rect &dest) const
std::set< Character * > getCharactersIn (Uint16 mask, const SDL_Rect &rect, bool touch=false, Uint16 radius=0, Uint16 dir=DIR_ALL) const
std::set< Object * > getObjectsIn (Uint16 mask, const SDL_Rect &rect, bool touch=false, Uint16 radius=0, Uint16 dir=DIR_ALL) const
ObjectgetObjectAt (Sint16 x, Sint16 y, Uint16 mask=ALL) const
 Returns the first found object at the given position.
Uint16 getDirection (const SDL_Rect &src, const SDL_Rect &dest) const
int loadScenario (string scenarioname)
 Load a new scenario.
void newMap (const ParameterMap &bg_parameters)
 Create a new empty map with the specified background.
int loadMapBuf (string mapname)
 Used to load the map file into a buffer.
int reloadMap ()
 Reload the map file using the buffered map file.
int loadMap (string mapname)
 Loads and initializes the map data.
int loadMap (Uint8 level=0)
void loadNextMap ()
int startScenario ()
void winScenario ()
void resetScenario ()

Public Attributes

Backgroundbackground
 Background.
SDL_Rect * area
 Size of the background (map area).
Playerplayer
 Current player.
ImageCacheimgcache
 Image Cache.
SoundCachesndcache
 Sound Cache.
ObjectsPoolpool
 Object pool.
PhysicHandlerphysic
 Physic Handler.
bool failed
 True if the mission failed.
bool finnished
 True if the mission is finnished (suceeded or failed).
string mapname
 Name of the current map file.
string scenarioname
 Name of the scenario.
string bgimage
 Name of the map background image.
std::vector< string > mapbuf
Uint32 max_obj_num
 The number of created objects.
std::vector< string > maps
std::vector< string > playlist
Uint8 currentmap

Detailed Description

Scenario organization.

Loads the corresponding map data (objects) and performs location checks.

Remarks:
MAP FORMAT:

HeaderOption "parameters"

Background "parameters"

#ENDHEADER

"Object class name" "x position" "y position" "parameters"

The parameters depend on the object: Each object checks it's corresponding parameters.

The parameter format is like this:

option1=value1,option2=value2,...

A value may be a parameterlist of suboptions:

option1=subopt1=subval1:subopt2=subval2:...,option2=value2

Defaults:

x and y default to 0

Example:

Background image=background.bmp

#ENDHEADER

Teleporter 0 0 image=teleporter.bmp,exitx=20,exity=100,name=teleporter1

Todo:
Move the Caches into the current map as well?


Member Function Documentation

Hit Scenario::checkPlace const SDL_Rect &  src,
const SDL_Rect &  dest
const
 

Checks where the source rectangle overlaps the destination rectangle.

Parameters:
src Source rectangle
dest Destination rectangle
Returns:
Hit Directions of overlapping. DIR_ALL if the destination rectangle is inside the source rectangle, NOTHING if the source rectangle is inside the destionation rectangle.

std::set<Character *> Scenario::getCharactersIn Uint16  mask,
const SDL_Rect &  rect,
bool  touch = false,
Uint16  radius = 0,
Uint16  dir = DIR_ALL
const
 

Parameters:
mask Mask for the object types that this function should match (default: all Characters).
rect Base region of the target area that should be checked.
touch If true an touch (overlapping of area) is enough for a match, otherwise the center of the specified rectangle has to be inside the target.
radius This enlarges the base area by this amount into all specified directions (default: 0)
dir Search directions (default: all)
Returns:
A set of characters that are inside the enlarged source rectangle and that match the specified mask.

Uint16 Scenario::getDirection const SDL_Rect &  src,
const SDL_Rect &  dest
const
 

Returns the directions from the source rectangle to the destination rectangle

Remarks:
This may include an enlargment (eg. Olaf)
Parameters:
src Source rectangle
dest Destination rectangle

int Scenario::loadMap string  mapname  ) 
 

Loads and initializes the map data.

Parses the map file and tries to add the objects by using addObjectByName()

Parameters:
mapname Map file name without the data directory in it
Returns:
0 if a Background was found, -1 if not, -2 if the loading failed


The documentation for this class was generated from the following file:
Generated on Sun Feb 5 13:02:38 2006 for Lost Penguins by doxygen 1.3.8