4 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include "tile_manager.hpp"
28 #include "game_session.hpp"
29 #include "gameobjs.hpp"
30 #include "sprite/sprite_manager.hpp"
31 #include "sprite/sprite.hpp"
32 #include "resources.hpp"
34 #include "tilemap.hpp"
35 #include "video/drawing_context.hpp"
38 #include "random_generator.hpp"
40 BouncyCoin::BouncyCoin(const Vector& pos)
44 sprite = sprite_manager->create("images/objects/coin/coin.sprite");
45 sprite->set_action("still");
48 BouncyCoin::~BouncyCoin()
54 BouncyCoin::update(float elapsed_time)
56 position.y += -200 * elapsed_time;
63 BouncyCoin::draw(DrawingContext& context)
65 sprite->draw(context, position, LAYER_OBJECTS + 5);
68 //---------------------------------------------------------------------------
70 BrokenBrick::BrokenBrick(Sprite* nsprite,
71 const Vector& pos, const Vector& nmovement)
72 : sprite(new Sprite(*nsprite)), position(pos), movement(nmovement)
77 BrokenBrick::~BrokenBrick()
83 BrokenBrick::update(float elapsed_time)
85 position += movement * elapsed_time;
92 BrokenBrick::draw(DrawingContext& context)
94 sprite->draw_part(context,
95 Vector(systemRandom.rand(16), systemRandom.rand(16)), Vector(16, 16),
96 position, LAYER_OBJECTS + 1);
99 //---------------------------------------------------------------------------
101 FloatingText::FloatingText(const Vector& pos, const std::string& text_)
102 : position(pos), text(text_)
105 position.x -= text.size() * 8;
108 FloatingText::FloatingText(const Vector& pos, int score)
113 // turn int into a string
115 snprintf(str, 10, "%d", score);
118 position.x -= text.size() * 8;
122 FloatingText::update(float elapsed_time)
124 position.y -= 1.4 * elapsed_time;
130 #define FADING_TIME .350
133 FloatingText::draw(DrawingContext& context)
135 // make an alpha animation when disapearing
137 if(timer.get_timeleft() < FADING_TIME)
138 alpha = int(timer.get_timeleft() * 255 / FADING_TIME);
142 context.push_transform();
143 context.set_alpha(alpha);
145 context.draw_text(gold_text, text, position, ALIGN_LEFT, LAYER_OBJECTS+1);
147 context.pop_transform();
150 Sprite *img_smoke_cloud = 0;
152 SmokeCloud::SmokeCloud(const Vector& pos)
156 sprite = sprite_manager->create("images/objects/particles/stomp.sprite");
159 SmokeCloud::~SmokeCloud()
165 SmokeCloud::update(float elapsed_time)
167 position.y -= 120 * elapsed_time;
174 SmokeCloud::draw(DrawingContext& context)
176 sprite->draw(context, position, LAYER_OBJECTS+1);