X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fobject%2Fflower.cpp;h=f3bcdca5c8ffb69dfd9a6f194b2b5ffcd46f996a;hb=2b4d3758e0f8d3a8de962f85eea5a4ada723706d;hp=b5830e0a9f76539c0d5107a1d69ce56ea0aef6c5;hpb=2892ebda09d24c977547159e34abf0244884b89e;p=supertux.git diff --git a/src/object/flower.cpp b/src/object/flower.cpp index b5830e0a9..f3bcdca5c 100644 --- a/src/object/flower.cpp +++ b/src/object/flower.cpp @@ -1,12 +1,10 @@ -// $Id$ -// // SuperTux // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,32 +12,33 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include +// along with this program. If not, see . -#include -#include -#include "flower.hpp" -#include "resources.hpp" -#include "camera.hpp" -#include "sector.hpp" -#include "player.hpp" #include "audio/sound_manager.hpp" +#include "object/flower.hpp" +#include "object/player.hpp" +#include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" -Flower::Flower(BonusType _type) - : type(_type) +Flower::Flower(BonusType _type) : + type(_type), + sprite(), + drawing_effect(NO_EFFECT), + light(1.0f,1.0f,1.0f), + lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")) { bbox.set_size(32, 32); - + lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE)); + if(type == FIRE_BONUS) { sprite = sprite_manager->create("images/powerups/fireflower/fireflower.sprite"); sound_manager->preload("sounds/fire-flower.wav"); + lightsprite->set_color(Color(0.3f, 0.0f, 0.0f)); } else if(type == ICE_BONUS) { - sprite = sprite_manager->create("images/powerups/iceflower/iceflower.sprite"); + sprite = sprite_manager->create("images/powerups/iceflower/iceflower.sprite"); + sound_manager->preload("sounds/fire-flower.wav"); + lightsprite->set_color(Color(0.0f, 0.1f, 0.2f)); } else { assert(false); } @@ -49,7 +48,6 @@ Flower::Flower(BonusType _type) Flower::~Flower() { - delete sprite; } void @@ -60,7 +58,16 @@ Flower::update(float ) void Flower::draw(DrawingContext& context) { - sprite->draw(context, get_pos(), LAYER_OBJECTS); + //Draw the Sprite. + sprite->draw(context, get_pos(), LAYER_OBJECTS, drawing_effect); + //Draw the light when dark + context.get_light( get_bbox().get_middle(), &light ); + if (light.red + light.green + light.blue < 3.0){ + context.push_target(); + context.set_target(DrawingContext::LIGHTMAP); + lightsprite->draw(context, get_bbox().get_middle(), 0); + context.pop_target(); + } } HitResponse @@ -72,9 +79,10 @@ Flower::collision(GameObject& other, const CollisionHit& ) if(!player->add_bonus(type, true)) return FORCE_MOVE; - + sound_manager->play("sounds/fire-flower.wav"); remove_me(); return ABORT_MOVE; } +/* EOF */