X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fmagicblock.cpp;h=99135de94b0623324e634d3372c8cd5295a66659;hb=555d1b7bebb45326d82d934e07463209837309b0;hp=31fcf5ef1e61c8a30c269dd740a8659d8f44f542;hpb=567f43b64a62a3f2b4874287c02eba1560e6e436;p=supertux.git diff --git a/src/object/magicblock.cpp b/src/object/magicblock.cpp index 31fcf5ef1..99135de94 100644 --- a/src/object/magicblock.cpp +++ b/src/object/magicblock.cpp @@ -2,7 +2,7 @@ // // SuperTux - MagicBlock // -// Magic Blocks are tile-like game objects that are sensitive to +// Magic Blocks are tile-like game objects that are sensitive to // lighting conditions. They are rendered in a color and // will only be solid as long as light of the same color shines // on the block. @@ -34,15 +34,15 @@ #include "main.hpp" namespace { - const float MIN_INTENSITY = 0.8; - const float ALPHA_SOLID = 0.7; - const float ALPHA_NONSOLID = 0.3; - const float MIN_SOLIDTIME = 1.0; - const float SWITCH_DELAY = 0.1; /**< seconds to wait for stable conditions until switching solidity */ + const float MIN_INTENSITY = 0.8f; + const float ALPHA_SOLID = 0.7f; + const float ALPHA_NONSOLID = 0.3f; + const float MIN_SOLIDTIME = 1.0f; + const float SWITCH_DELAY = 0.1f; /**< seconds to wait for stable conditions until switching solidity */ } MagicBlock::MagicBlock(const lisp::Lisp& lisp) - : MovingSprite(lisp, "images/objects/magicblock/magicblock.sprite"), + : MovingSprite(lisp, "images/objects/magicblock/magicblock.sprite"), is_solid(false), solid_time(0), switch_delay(0), light(1.0f,1.0f,1.0f) { set_group(COLGROUP_STATIC); @@ -73,7 +73,7 @@ MagicBlock::MagicBlock(const lisp::Lisp& lisp) void MagicBlock::update(float elapsed_time) { - //Check if center of this block is on screen. + //Check if center of this block is on screen. //Don't update if not, because there is no light off screen. float screen_left = Sector::current()->camera->get_translation().x; float screen_top = Sector::current()->camera->get_translation().y; @@ -144,14 +144,16 @@ MagicBlock::draw(DrawingContext& context){ context.draw_filled_rect( get_bbox(), color, layer); } +bool +MagicBlock::collides(GameObject& /*other*/, const CollisionHit& /*hit*/) +{ + return is_solid; +} + HitResponse MagicBlock::collision(GameObject& /*other*/, const CollisionHit& /*hit*/) { - if(is_solid) { - return SOLID; - } else { - return PASSTHROUGH; - } + return SOLID; } IMPLEMENT_FACTORY(MagicBlock, "magicblock");