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
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

SDL_Rect * area
 Size of the background (map area).
 Current player.
 Image Cache.
 Sound Cache.
 Object pool.
 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.


HeaderOption "parameters"

Background "parameters"


"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:


A value may be a parameterlist of suboptions:



x and y default to 0


Background image=background.bmp


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

Move the Caches into the current map as well?

Member Function Documentation

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

Checks where the source rectangle overlaps the destination rectangle.

src Source rectangle
dest Destination rectangle
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

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)
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

Returns the directions from the source rectangle to the destination rectangle

This may include an enlargment (eg. Olaf)
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()

mapname Map file name without the data directory in it
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