hoa_map::private_map::MapSprite Class Reference

A mobile map object with which the player can interact with. More...

#include <map_sprites.h>

Inheritance diagram for hoa_map::private_map::MapSprite:

Inheritance graph
[legend]
Collaboration diagram for hoa_map::private_map::MapSprite:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void Draw ()
 Draws the sprite frame in the appropriate position on the screen, if it is visible.
bool LoadStandardAnimations (std::string filename)
 Loads the image containing the standard animations for the sprite.
virtual bool LoadState ()
 This method will load the saved state of a sprite. Attributes loaded: direction, speed, moving state, name, current action, current animation, current walk sound.
 MapSprite ()
virtual void SaveState ()
 This method will save the state of a sprite. Attributes saved: direction, speed, moving state, name, current action, current animation, current walk sound.
virtual void Update ()
 Updates the sprite's position and state.
 ~MapSprite ()
Lua Access Functions
These functions are specifically written for Lua binding, to enable Lua to access the members of this class.

uint8 GetCurrentAnimation () const
int8 GetWalkSound () const
void SetCurrentAnimation (uint8 anim)
void SetName (std::string na)
void SetWalkSound (int8 sound)

Public Attributes

std::vector< hoa_video::AnimatedImageanimations
 A vector containing all the sprite's various animations. The first four entries in this vector are the walking animation frames. They are ordered from index 0 to 3 as: down, up, left, right. Additional animations may follow.
uint8 current_animation
 The index to the animations vector containing the current sprite image to display.
int8 walk_sound
 The sound that will play when the sprite walks. This member references the MapMode::_map_sounds vector as the sound to play. If this member is less than zero, no sound is played when the object is walking.
bool was_moving
 Holds the previous value of VirtualSprite::moving from the last call to MapSprite::Update().
Saved state attributes
These attributes are used to save and load the state of a VirtualSprite

uint8 _saved_current_animation
int8 _saved_walk_sound
bool _saved_was_moving

Detailed Description

A mobile map object with which the player can interact with.

****************************************************************************

Map sprites are animate, mobile, living map objects. Although there is but this single class to represent all the map sprites in the game, they can divided into types such as NPCs, friendly creatures, and enemies. The fact that there is only one class for representing several sprite types is the reason why many of the class members are pointers. For example, we don't need dialogue for a dog sprite.

Definition at line 294 of file map_sprites.h.


Constructor & Destructor Documentation

hoa_map::private_map::MapSprite::MapSprite (  ) 

Definition at line 368 of file map_sprites.cpp.

References hoa_map::private_map::MapObject::_object_type, hoa_map::private_map::VirtualSprite::face_portrait, and hoa_map::private_map::SPRITE_TYPE.

hoa_map::private_map::MapSprite::~MapSprite (  ) 

Definition at line 379 of file map_sprites.cpp.

References animations, hoa_video::GameVideo::DeleteImage(), hoa_map::private_map::VirtualSprite::face_portrait, and hoa_video::VideoManager.

Here is the call graph for this function:


Member Function Documentation

void hoa_map::private_map::MapSprite::Draw (  )  [virtual]

Draws the sprite frame in the appropriate position on the screen, if it is visible.

Reimplemented from hoa_map::private_map::VirtualSprite.

Reimplemented in hoa_map::private_map::EnemySprite.

Definition at line 533 of file map_sprites.cpp.

References animations, current_animation, hoa_map::private_map::VirtualSprite::Draw(), hoa_map::private_map::MapObject::DrawHelper(), hoa_video::GameVideo::DrawImage(), and hoa_video::VideoManager.

Here is the call graph for this function:

uint8 hoa_map::private_map::MapSprite::GetCurrentAnimation (  )  const [inline]

Definition at line 359 of file map_sprites.h.

References current_animation.

int8 hoa_map::private_map::MapSprite::GetWalkSound (  )  const [inline]

Definition at line 356 of file map_sprites.h.

References walk_sound.

bool hoa_map::private_map::MapSprite::LoadStandardAnimations ( std::string  filename  ) 

Loads the image containing the standard animations for the sprite.

Parameters:
filename The name of the image file holding the standard walking animations
Returns:
False if there was a problem loading the sprite.

Definition at line 397 of file map_sprites.cpp.

References animations, hoa_map::private_map::MapObject::img_half_width, hoa_map::private_map::MapObject::img_height, hoa_video::GameVideo::LoadMultiImageFromNumberElements(), hoa_map::private_map::VirtualSprite::movement_speed, and hoa_video::VideoManager.

Referenced by hoa_map::private_map::EnemySprite::Load().

Here is the call graph for this function:

bool hoa_map::private_map::MapSprite::LoadState (  )  [virtual]

This method will load the saved state of a sprite. Attributes loaded: direction, speed, moving state, name, current action, current animation, current walk sound.

Returns:
false if there was no saved state, true otherwise.

Reimplemented from hoa_map::private_map::VirtualSprite.

Definition at line 552 of file map_sprites.cpp.

References _saved_current_animation, _saved_walk_sound, _saved_was_moving, current_animation, hoa_map::private_map::VirtualSprite::LoadState(), walk_sound, and was_moving.

Here is the call graph for this function:

void hoa_map::private_map::MapSprite::SaveState (  )  [virtual]

This method will save the state of a sprite. Attributes saved: direction, speed, moving state, name, current action, current animation, current walk sound.

Reimplemented from hoa_map::private_map::VirtualSprite.

Definition at line 542 of file map_sprites.cpp.

References _saved_current_animation, _saved_walk_sound, _saved_was_moving, current_animation, hoa_map::private_map::VirtualSprite::SaveState(), walk_sound, and was_moving.

Here is the call graph for this function:

void hoa_map::private_map::MapSprite::SetCurrentAnimation ( uint8  anim  )  [inline]

Definition at line 353 of file map_sprites.h.

References current_animation.

void hoa_map::private_map::MapSprite::SetName ( std::string  na  )  [inline]

Definition at line 347 of file map_sprites.h.

References hoa_utils::MakeUnicodeString(), and hoa_map::private_map::VirtualSprite::name.

Here is the call graph for this function:

void hoa_map::private_map::MapSprite::SetWalkSound ( int8  sound  )  [inline]

Definition at line 350 of file map_sprites.h.

References walk_sound.

void hoa_map::private_map::MapSprite::Update (  )  [virtual]

Updates the sprite's position and state.

Reimplemented from hoa_map::private_map::VirtualSprite.

Reimplemented in hoa_map::private_map::EnemySprite.

Definition at line 462 of file map_sprites.cpp.

References hoa_map::private_map::ANIM_STANDING_EAST, hoa_map::private_map::ANIM_STANDING_NORTH, hoa_map::private_map::ANIM_STANDING_SOUTH, hoa_map::private_map::ANIM_STANDING_WEST, hoa_map::private_map::ANIM_WALKING_EAST, hoa_map::private_map::ANIM_WALKING_NORTH, hoa_map::private_map::ANIM_WALKING_SOUTH, hoa_map::private_map::ANIM_WALKING_WEST, animations, hoa_map::private_map::VirtualSprite::current_action, current_animation, hoa_map::private_map::VirtualSprite::direction, hoa_map::private_map::FACING_EAST, hoa_map::private_map::FACING_NORTH, hoa_map::private_map::FACING_SOUTH, hoa_map::private_map::FACING_WEST, hoa_map::private_map::VirtualSprite::moving, hoa_map::private_map::VirtualSprite::Update(), and was_moving.

Referenced by hoa_map::private_map::EnemySprite::Update().

Here is the call graph for this function:


Member Data Documentation

uint8 hoa_map::private_map::MapSprite::_saved_current_animation

Definition at line 321 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

int8 hoa_map::private_map::MapSprite::_saved_walk_sound

Definition at line 320 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

bool hoa_map::private_map::MapSprite::_saved_was_moving

Definition at line 319 of file map_sprites.h.

Referenced by LoadState(), and SaveState().

std::vector<hoa_video::AnimatedImage> hoa_map::private_map::MapSprite::animations

A vector containing all the sprite's various animations. The first four entries in this vector are the walking animation frames. They are ordered from index 0 to 3 as: down, up, left, right. Additional animations may follow.

Definition at line 313 of file map_sprites.h.

Referenced by hoa_map::private_map::EnemySprite::Draw(), Draw(), LoadStandardAnimations(), Update(), and ~MapSprite().

uint8 hoa_map::private_map::MapSprite::current_animation

The index to the animations vector containing the current sprite image to display.

Definition at line 306 of file map_sprites.h.

Referenced by hoa_map::private_map::EnemySprite::Draw(), Draw(), GetCurrentAnimation(), LoadState(), SaveState(), SetCurrentAnimation(), and Update().

int8 hoa_map::private_map::MapSprite::walk_sound

The sound that will play when the sprite walks. This member references the MapMode::_map_sounds vector as the sound to play. If this member is less than zero, no sound is played when the object is walking.

Definition at line 303 of file map_sprites.h.

Referenced by GetWalkSound(), LoadState(), SaveState(), and SetWalkSound().

bool hoa_map::private_map::MapSprite::was_moving

Holds the previous value of VirtualSprite::moving from the last call to MapSprite::Update().

Definition at line 297 of file map_sprites.h.

Referenced by LoadState(), SaveState(), and Update().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:14:56 2007 for Hero of Allacrost by  doxygen 1.5.1