worldmap::SpecialTile Class Reference

#include <special_tile.hpp>

Inherits GameObject.

List of all members.

Public Member Functions

 SpecialTile (const Reader &lisp)
virtual ~SpecialTile ()
virtual void draw (DrawingContext &context)
 The GameObject should draw itself onto the provided DrawingContext if this function is called.
virtual void update (float elapsed_time)
 This function is called once per frame and allows the object to update it's state.

Public Attributes

Vector pos
SpritePtr sprite
 Sprite to render instead of guessing what image to draw.
std::string map_message
 Message to show in the Map.
bool passive_message
std::string script
 Script to execute when tile is touched.
bool invisible
 Hide special tile.
bool apply_action_north
 Only applies actions (ie.
bool apply_action_east
bool apply_action_south
bool apply_action_west


Detailed Description

Definition at line 31 of file special_tile.hpp.


Constructor & Destructor Documentation

worldmap::SpecialTile::SpecialTile ( const Reader lisp  ) 

Definition at line 27 of file special_tile.cpp.

References apply_action_east, apply_action_north, apply_action_south, apply_action_west, SpriteManager::create(), lisp::Lisp::get(), invisible, map_message, passive_message, pos, script, sprite, sprite_manager, Vector::x, and Vector::y.

00027                                            :
00028   pos(),
00029   sprite(),
00030   map_message(),
00031   passive_message(false), 
00032   script(),
00033   invisible(false),
00034   apply_action_north(true), 
00035   apply_action_east(true),
00036   apply_action_south(true), 
00037   apply_action_west(true)
00038 {
00039   lisp.get("x", pos.x);
00040   lisp.get("y", pos.y);
00041   lisp.get("invisible-tile", invisible);
00042 
00043   if(!invisible) {
00044     std::string spritefile = "";
00045     lisp.get("sprite", spritefile);
00046     sprite = sprite_manager->create(spritefile);
00047   }
00048 
00049   lisp.get("map-message", map_message);
00050   lisp.get("passive-message", passive_message);
00051   lisp.get("script", script);
00052 
00053   std::string apply_direction;
00054   lisp.get("apply-to-direction", apply_direction);
00055   if(!apply_direction.empty()) {
00056     apply_action_north = false;
00057     apply_action_south = false;
00058     apply_action_east = false;
00059     apply_action_west = false;
00060     if(apply_direction.find("north") != std::string::npos)
00061       apply_action_north = true;
00062     if(apply_direction.find("south") != std::string::npos)
00063       apply_action_south = true;
00064     if(apply_direction.find("east") != std::string::npos)
00065       apply_action_east = true;
00066     if(apply_direction.find("west") != std::string::npos)
00067       apply_action_west = true;
00068   }
00069 }

worldmap::SpecialTile::~SpecialTile (  )  [virtual]

Definition at line 71 of file special_tile.cpp.

00072 {
00073 }


Member Function Documentation

void worldmap::SpecialTile::draw ( DrawingContext context  )  [virtual]

The GameObject should draw itself onto the provided DrawingContext if this function is called.

Implements GameObject.

Definition at line 76 of file special_tile.cpp.

References invisible, LAYER_OBJECTS, pos, and sprite.

00077 {
00078   if(invisible)
00079     return;
00080 
00081   sprite->draw(context, pos*32 + Vector(16, 16), LAYER_OBJECTS - 1);
00082 }

void worldmap::SpecialTile::update ( float  elapsed_time  )  [virtual]

This function is called once per frame and allows the object to update it's state.

The elapsed_time is the time since the last frame in seconds and should be the base for all timed calculations (don't use SDL_GetTicks directly as this will fail in pause mode)

Implements GameObject.

Definition at line 85 of file special_tile.cpp.

00086 {
00087 }


Member Data Documentation

Vector worldmap::SpecialTile::pos

Definition at line 41 of file special_tile.hpp.

Referenced by draw(), and SpecialTile().

SpritePtr worldmap::SpecialTile::sprite

Sprite to render instead of guessing what image to draw.

Definition at line 44 of file special_tile.hpp.

Referenced by draw(), and SpecialTile().

std::string worldmap::SpecialTile::map_message

Message to show in the Map.

Definition at line 47 of file special_tile.hpp.

Referenced by SpecialTile(), and worldmap::Tux::tryContinueWalking().

bool worldmap::SpecialTile::passive_message

Definition at line 48 of file special_tile.hpp.

Referenced by SpecialTile(), and worldmap::Tux::tryContinueWalking().

std::string worldmap::SpecialTile::script

Script to execute when tile is touched.

Definition at line 51 of file special_tile.hpp.

Referenced by SpecialTile(), and worldmap::Tux::tryContinueWalking().

bool worldmap::SpecialTile::invisible

Hide special tile.

Definition at line 54 of file special_tile.hpp.

Referenced by draw(), and SpecialTile().

bool worldmap::SpecialTile::apply_action_north

Only applies actions (ie.

passive messages) when going to that direction

Definition at line 57 of file special_tile.hpp.

Referenced by SpecialTile(), and worldmap::Tux::tryContinueWalking().

bool worldmap::SpecialTile::apply_action_east

Definition at line 58 of file special_tile.hpp.

Referenced by SpecialTile(), and worldmap::Tux::tryContinueWalking().

bool worldmap::SpecialTile::apply_action_south

Definition at line 59 of file special_tile.hpp.

Referenced by SpecialTile(), and worldmap::Tux::tryContinueWalking().

bool worldmap::SpecialTile::apply_action_west

Definition at line 60 of file special_tile.hpp.

Referenced by SpecialTile(), and worldmap::Tux::tryContinueWalking().


The documentation for this class was generated from the following files:
Generated on Mon Apr 14 03:38:52 2014 for SuperTux by  doxygen 1.5.1