worldmap::LevelTile Class Reference

#include <level.hpp>

Inherits GameObject.

List of all members.

Public Member Functions

 LevelTile (const std::string &basedir, const Reader &lisp)
virtual ~LevelTile ()
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
std::string title
bool solved
bool auto_play
 true if Tux should automatically enter this level if it's unfinished
SpritePtr sprite
Statistics statistics
 Statistics for level tiles.
std::string extro_script
 Script that is run when the level is successfully finished.

Private Member Functions

 LevelTile (const LevelTile &)
LevelTileoperator= (const LevelTile &)

Private Attributes

std::string basedir
bool picture_cached
Surfacepicture


Detailed Description

Definition at line 33 of file level.hpp.


Constructor & Destructor Documentation

worldmap::LevelTile::LevelTile ( const std::string &  basedir,
const Reader lisp 
)

Definition at line 32 of file level.cpp.

References auto_play, SpriteManager::create(), extro_script, lisp::Lisp::get(), log_warning, GameObject::name, pos, sprite, sprite_manager, Vector::x, and Vector::y.

00032                                                                  :
00033   pos(),
00034   title(),
00035   solved(false), 
00036   auto_play(false), 
00037   sprite(),
00038   statistics(),
00039   extro_script(),
00040   basedir(basedir), 
00041   picture_cached(false),
00042   picture(0)
00043 {
00044   lisp.get("name", name);
00045   lisp.get("x", pos.x);
00046   lisp.get("y", pos.y);
00047   lisp.get("auto-play", auto_play);
00048 
00049   std::string spritefile = "images/worldmap/common/leveldot.sprite";
00050   lisp.get("sprite", spritefile);
00051   sprite = sprite_manager->create(spritefile);
00052 
00053   lisp.get("extro-script", extro_script);
00054 
00055   if (!PHYSFS_exists((basedir + name).c_str()))
00056   {
00057     log_warning << "level file '" << name
00058                 << "' does not exist and will not be added to the worldmap" << std::endl;
00059     return;
00060   }
00061 }

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

Definition at line 63 of file level.cpp.

References picture.

00064 {
00065   delete picture;
00066 }

worldmap::LevelTile::LevelTile ( const LevelTile  )  [private]


Member Function Documentation

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

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

Implements GameObject.

Definition at line 69 of file level.cpp.

References LAYER_OBJECTS, pos, and sprite.

00070 {
00071   sprite->draw(context, pos*32 + Vector(16, 16), LAYER_OBJECTS - 1);
00072 }

void worldmap::LevelTile::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 75 of file level.cpp.

00076 {
00077 }

LevelTile& worldmap::LevelTile::operator= ( const LevelTile  )  [private]


Member Data Documentation

Vector worldmap::LevelTile::pos

Definition at line 43 of file level.hpp.

Referenced by draw(), LevelTile(), and worldmap::WorldMap::update().

std::string worldmap::LevelTile::title

Definition at line 44 of file level.hpp.

Referenced by worldmap::WorldMap::get_level_title().

bool worldmap::LevelTile::solved

Definition at line 45 of file level.hpp.

Referenced by worldmap::WorldMap::finished_level(), worldmap::Tux::tryStartWalking(), and worldmap::WorldMap::update().

bool worldmap::LevelTile::auto_play

true if Tux should automatically enter this level if it's unfinished

Definition at line 46 of file level.hpp.

Referenced by LevelTile(), and worldmap::WorldMap::update().

SpritePtr worldmap::LevelTile::sprite

Definition at line 48 of file level.hpp.

Referenced by draw(), worldmap::WorldMap::finished_level(), and LevelTile().

Statistics worldmap::LevelTile::statistics

Statistics for level tiles.

Definition at line 51 of file level.hpp.

Referenced by worldmap::WorldMap::finished_level(), and worldmap::WorldMap::update().

std::string worldmap::LevelTile::extro_script

Script that is run when the level is successfully finished.

Definition at line 54 of file level.hpp.

Referenced by worldmap::WorldMap::finished_level(), and LevelTile().

std::string worldmap::LevelTile::basedir [private]

Definition at line 57 of file level.hpp.

bool worldmap::LevelTile::picture_cached [private]

Definition at line 58 of file level.hpp.

Surface* worldmap::LevelTile::picture [private]

Definition at line 59 of file level.hpp.

Referenced by ~LevelTile().


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