BrokenBrick Class Reference

#include <broken_brick.hpp>

Inherits GameObject.

List of all members.

Public Member Functions

 BrokenBrick (SpritePtr sprite, const Vector &pos, const Vector &movement)
 ~BrokenBrick ()
virtual void update (float elapsed_time)
 This function is called once per frame and allows the object to update it's state.
virtual void draw (DrawingContext &context)
 The GameObject should draw itself onto the provided DrawingContext if this function is called.

Private Member Functions

 BrokenBrick (const BrokenBrick &)
BrokenBrickoperator= (const BrokenBrick &)

Private Attributes

Timer timer
SpritePtr sprite
Vector position
Vector movement


Detailed Description

Definition at line 28 of file broken_brick.hpp.


Constructor & Destructor Documentation

BrokenBrick::BrokenBrick ( SpritePtr  sprite,
const Vector pos,
const Vector movement 
)

Definition at line 22 of file broken_brick.cpp.

References Timer::start(), and timer.

00023                                                                      :
00024   timer(),
00025   sprite(sprite), 
00026   position(pos), 
00027   movement(nmovement)
00028 {
00029   timer.start(.2f);
00030 }

BrokenBrick::~BrokenBrick (  ) 

Definition at line 32 of file broken_brick.cpp.

00033 {
00034 }

BrokenBrick::BrokenBrick ( const BrokenBrick  )  [private]


Member Function Documentation

void BrokenBrick::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 37 of file broken_brick.cpp.

References Timer::check(), movement, position, GameObject::remove_me(), and timer.

00038 {
00039   position += movement * elapsed_time;
00040 
00041   if (timer.check())
00042     remove_me();
00043 }

void BrokenBrick::draw ( DrawingContext context  )  [virtual]

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

Implements GameObject.

Definition at line 46 of file broken_brick.cpp.

References graphicsRandom, LAYER_OBJECTS, position, RandomGenerator::rand(), and sprite.

00047 {
00048   sprite->draw_part(context,
00049                     Vector(graphicsRandom.rand(16), graphicsRandom.rand(16)), Vector(16, 16),
00050                     position, LAYER_OBJECTS + 1);
00051 }

BrokenBrick& BrokenBrick::operator= ( const BrokenBrick  )  [private]


Member Data Documentation

Timer BrokenBrick::timer [private]

Definition at line 38 of file broken_brick.hpp.

Referenced by BrokenBrick(), and update().

SpritePtr BrokenBrick::sprite [private]

Definition at line 39 of file broken_brick.hpp.

Referenced by draw().

Vector BrokenBrick::position [private]

Definition at line 40 of file broken_brick.hpp.

Referenced by draw(), and update().

Vector BrokenBrick::movement [private]

Definition at line 41 of file broken_brick.hpp.

Referenced by update().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:28 2014 for SuperTux by  doxygen 1.5.1