InvisibleBlock Class Reference

#include <invisible_block.hpp>

Inherits Block.

List of all members.

Public Member Functions

 InvisibleBlock (const Vector &pos)
virtual void draw (DrawingContext &context)
 The GameObject should draw itself onto the provided DrawingContext if this function is called.
virtual bool collides (GameObject &other, const CollisionHit &hit)
 when 2 objects collided, we will first call the pre_collision_check functions of both objects that can decide on how to react to the collision.
virtual HitResponse collision (GameObject &other, const CollisionHit &hit)
 this function is called when the object collided with any other object

Protected Member Functions

virtual void hit (Player &player)

Private Attributes

bool visible


Detailed Description

Definition at line 22 of file invisible_block.hpp.


Constructor & Destructor Documentation

InvisibleBlock::InvisibleBlock ( const Vector pos  ) 

Definition at line 24 of file invisible_block.cpp.

References MovingObject::bbox, SoundManager::preload(), Rectf::set_pos(), and sound_manager.

00024                                                 :
00025    Block(sprite_manager->create("images/objects/bonus_block/invisibleblock.sprite")), 
00026    visible(false)
00027 {
00028   bbox.set_pos(pos);
00029   sound_manager->preload("sounds/brick.wav");
00030 }


Member Function Documentation

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

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

Reimplemented from Block.

Definition at line 33 of file invisible_block.cpp.

References MovingObject::get_pos(), LAYER_OBJECTS, Block::sprite, and visible.

00034 {
00035   if(visible)
00036     sprite->draw(context, get_pos(), LAYER_OBJECTS);
00037 }

bool InvisibleBlock::collides ( GameObject other,
const CollisionHit hit 
) [virtual]

when 2 objects collided, we will first call the pre_collision_check functions of both objects that can decide on how to react to the collision.

Reimplemented from MovingObject.

Definition at line 40 of file invisible_block.cpp.

References MovingObject::get_bbox(), Rectf::get_bottom(), MovingObject::get_movement(), Rectf::get_top(), SHIFT_DELTA, visible, and Vector::y.

00041 {
00042   if(visible)
00043     return true;
00044 
00045   // if we're not visible, only register a collision if this will make us visible
00046   Player* player = dynamic_cast<Player*> (&other);
00047   if ((player) 
00048       && (player->get_movement().y <= 0)
00049       && (player->get_bbox().get_top() > get_bbox().get_bottom() - SHIFT_DELTA)) {
00050     return true;
00051   }
00052 
00053   return false;
00054 }

HitResponse InvisibleBlock::collision ( GameObject other,
const CollisionHit hit 
) [virtual]

this function is called when the object collided with any other object

Reimplemented from Block.

Definition at line 57 of file invisible_block.cpp.

References Block::collision(), and hit().

00058 {
00059   return Block::collision(other, hit);
00060 }

void InvisibleBlock::hit ( Player player  )  [protected, virtual]

Implements Block.

Definition at line 63 of file invisible_block.cpp.

References COLGROUP_STATIC, SoundManager::play(), MovingObject::set_group(), sound_manager, Block::sprite, Block::start_bounce(), and visible.

Referenced by collision().

00064 {
00065   sound_manager->play("sounds/brick.wav");
00066 
00067   if(visible)
00068     return;
00069 
00070   sprite->set_action("empty");
00071   start_bounce(&player);
00072   set_group(COLGROUP_STATIC);
00073   visible = true;
00074 }


Member Data Documentation

bool InvisibleBlock::visible [private]

Definition at line 35 of file invisible_block.hpp.

Referenced by collides(), draw(), and hit().


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