Adonthell  0.4
mapobject Class Reference

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

#include <mapobject.h>

Inheritance diagram for mapobject:
Collaboration diagram for mapobject:

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.
- Public Member Functions inherited from mapsquare_walkable_area
 mapsquare_walkable_area ()
 Default constructor.
 ~mapsquare_walkable_area ()
 Destructor.
mapsquare_walkable_areaoperator= (const mapsquare_walkable_area &mo)
 Area copy (similar to copy ()).
void copy (const mapsquare_walkable_area &src)
 Synonym of operator = to guarantee its access from Python.
u_int16 area_length () const
 Returns the length of the area.
u_int16 area_height () const
 Returns the height of the area.
mapsquare_walkableget_square (u_int16 x, u_int16 y) const
 Returns a pointer to a desired square.
void resize_area (u_int16 nl, u_int16 nh)
 Resize the area.
u_int16 base_x () const
 Returns the X offset of the base square of this object.
u_int16 base_y () const
 Returns the Y offset of the base square of this object.
void set_base (u_int16 nx, u_int16 ny)
 Sets the base square of this object.
- Public Member Functions inherited from drawable
 drawable ()
 Default constructor.
virtual ~drawable ()
 Destructor.
u_int16 length () const
 Returns the length of the drawable.
u_int16 height () const
 Returns the height of the drawable.
virtual bool input_update ()
 Virtual input update function, provided for objects which doesn't need one.

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:
xX position where to draw.
yY position where to draw.
da_optoptional drawing_area to use during the drawing operation.
targetpointer 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:
xX position where to draw.
yY position where to draw.
da_optoptional drawing_area to use during the drawing operation.
targetpointer 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:
filethe 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:
fnamethe 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:
fileopened 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:
fnamefile 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:
nbrindex 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:
anpointer to the animation to add.
posindex 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:
posThe 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: