mapobject Class Reference

Objects that can be placed on a landmap. More...

#include <mapobject.h>

Inheritance diagram for mapobject:

Inheritance graph
[legend]
Collaboration diagram for mapobject:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 mapobject ()
 Default constructor.
 ~mapobject ()
 Destructor.
void clear ()
 Resets the mapobject to its post-constructor state.
mapobjectoperator= (const mapobject &mo)
 Mapobject copy (similar to copy ()).
void copy (const mapobject &src)
 Synonym of operator = to guarantee its access from Python.
State updating.
bool update ()
 Updates the mapobject's state.
Drawing methods.
void draw (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const
 Draw the object on the screen.
void draw_from_base (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const
 Similar to draw (), but assume the x and y parameters are where the base square should appear.
Loading/saving methods.
Note:
You can't save a mapobject with this class.


s_int8 get (igzstream &file)
 Loads a mapobject from an opened file.
s_int8 load (string fname)
 Loads a mapobject from it's filename.
s_int8 put (ogzstream &file) const
 Saves an mapobject into an opened file, in game format, with alpha and mask values.
s_int8 save (string fname) const
 Saves an mapobject into an file, in game format, with alpha and mask values.
Individual animations manipulation.
u_int16 nbr_of_animations () const
 Returns the number of animations of this mapobject.
animationget_animation (u_int16 nbr)
 Returns a pointer to one of the mapobject's animations.
s_int8 insert_animation (animation *an, u_int16 pos)
 Inserts an animation at a given position of the animations array.
s_int8 delete_animation (u_int16 pos)
 Removes an animation at a given position.


Detailed Description

Objects that can be placed on a landmap.

A mapobject is basically a set of animations. Each animation can be freely placed on a resizeable grid which represents the actual land where the object will be placed. This grid also has information about the walkability of it's squares, which will be repercuted on the landmap as soon as the object is placed.

Definition at line 46 of file mapobject.h.


Constructor & Destructor Documentation

mapobject::mapobject (  ) 

Default constructor.

Definition at line 33 of file mapobject.cc.

mapobject::~mapobject (  ) 

Destructor.

Definition at line 38 of file mapobject.cc.


Member Function Documentation

void mapobject::clear (  ) 

Resets the mapobject to its post-constructor state.

Reimplemented from mapsquare_walkable_area.

Definition at line 43 of file mapobject.cc.

bool mapobject::update (  )  [virtual]

Updates the mapobject's state.

Reimplemented from drawable.

Definition at line 53 of file mapobject.cc.

void mapobject::draw ( s_int16  x,
s_int16  y,
const drawing_area da_opt = NULL,
surface target = NULL 
) const [virtual]

Draw the object on the screen.

Parameters:
x X position where to draw.
y Y position where to draw.
da_opt optional drawing_area to use during the drawing operation.
target pointer to the surface where to draw the drawable. If NULL, draw on the screen.

Implements mapsquare_walkable_area.

Definition at line 63 of file mapobject.cc.

void mapobject::draw_from_base ( s_int16  x,
s_int16  y,
const drawing_area da_opt = NULL,
surface target = NULL 
) const

Similar to draw (), but assume the x and y parameters are where the base square should appear.

Parameters:
x X position where to draw.
y Y position where to draw.
da_opt optional drawing_area to use during the drawing operation.
target pointer to the surface where to draw the drawable. If NULL, draw on the screen.

Definition at line 71 of file mapobject.cc.

s_int8 mapobject::get ( igzstream file  ) 

Loads a mapobject from an opened file.

Parameters:
file the opened file from which to load.
Returns:
0 in case of success, error code otherwise.

Reimplemented from mapsquare_walkable_area.

Definition at line 78 of file mapobject.cc.

s_int8 mapobject::load ( string  fname  ) 

Loads a mapobject from it's filename.

Parameters:
fname the name of the file to load.
Returns:
0 in case of success, error code otherwise.

Definition at line 103 of file mapobject.cc.

s_int8 mapobject::put ( ogzstream file  )  const

Saves an mapobject into an opened file, in game format, with alpha and mask values.

Warning:
as the mapobject which is saved comes from a screen's depth surface, it will be slightly altered during the save. If you want a class capable of saving mapobjects with full truecolor quality, use mapobject_edit instead.
Parameters:
file opened file where to save into.
Returns:
  • 0 in case of success.
  • -1 in case of error.
See also:
save ()

Reimplemented from mapsquare_walkable_area.

Definition at line 120 of file mapobject.cc.

s_int8 mapobject::save ( string  fname  )  const

Saves an mapobject into an file, in game format, with alpha and mask values.

Warning:
as the mapobject which is saved comes from a screen's depth surface, it will be slightly altered during the save. If you want a class capable of saving mapobjects with full truecolor quality, use mapobject_edit instead.
Parameters:
fname file name where to save into.
Returns:
  • 0 in case of success.
  • -1 in case of error.
See also:
put ()

Definition at line 138 of file mapobject.cc.

u_int16 mapobject::nbr_of_animations (  )  const [inline]

Returns the number of animations of this mapobject.

Returns:
the number of animations of this mapobject.

Definition at line 177 of file mapobject.h.

animation* mapobject::get_animation ( u_int16  nbr  )  [inline]

Returns a pointer to one of the mapobject's animations.

Parameters:
nbr index of the animation to get.
Returns:
pointer to the nbr animation.

Definition at line 189 of file mapobject.h.

s_int8 mapobject::insert_animation ( animation an,
u_int16  pos 
)

Inserts an animation at a given position of the animations array.

The mapobject will be responsible for freeing the inserted animation.

Parameters:
an pointer to the animation to add.
pos index where to add the animation.
Returns:
0 in case of success, error code otherwise.

Definition at line 155 of file mapobject.cc.

s_int8 mapobject::delete_animation ( u_int16  pos  ) 

Removes an animation at a given position.

The animation itself will also be deleted ().

Parameters:
pos The index of the animation to remove.
Returns:
0 in case of success, error code otherwise.

Definition at line 168 of file mapobject.cc.

mapobject & mapobject::operator= ( const mapobject mo  ) 

Mapobject copy (similar to copy ()).

Attention:
Not available from Python. Use copy () from Python instead.
See also:
copy ()

Definition at line 181 of file mapobject.cc.

void mapobject::copy ( const mapobject src  )  [inline]

Synonym of operator = to guarantee its access from Python.

See also:
operator =

Definition at line 235 of file mapobject.h.


The documentation for this class was generated from the following files:

Generated on Sun Mar 1 09:53:13 2009 for Adonthell by  doxygen 1.5.8