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"
39 BouncyCoin::BouncyCoin(const Vector& pos)
43 sprite = sprite_manager->create("images/objects/coin/coin.sprite");
44 sprite->set_action("still");
47 BouncyCoin::~BouncyCoin()
53 BouncyCoin::update(float elapsed_time)
55 position.y += -200 * elapsed_time;
62 BouncyCoin::draw(DrawingContext& context)
64 sprite->draw(context, position, LAYER_OBJECTS + 5);
67 //---------------------------------------------------------------------------
69 BrokenBrick::BrokenBrick(Sprite* nsprite,
70 const Vector& pos, const Vector& nmovement)
71 : sprite(new Sprite(*nsprite)), position(pos), movement(nmovement)
76 BrokenBrick::~BrokenBrick()
82 BrokenBrick::update(float elapsed_time)
84 position += movement * elapsed_time;
91 BrokenBrick::draw(DrawingContext& context)
93 sprite->draw_part(context,
94 Vector(rand() % 16, rand() % 16), Vector(16, 16),
95 position, LAYER_OBJECTS + 1);
98 //---------------------------------------------------------------------------
100 FloatingText::FloatingText(const Vector& pos, const std::string& text_)
101 : position(pos), text(text_)
104 position.x -= text.size() * 8;
107 FloatingText::FloatingText(const Vector& pos, int score)
112 // turn int into a string
114 snprintf(str, 10, "%d", score);
117 position.x -= text.size() * 8;
121 FloatingText::update(float elapsed_time)
123 position.y -= 1.4 * elapsed_time;
129 #define FADING_TIME .350
132 FloatingText::draw(DrawingContext& context)
134 // make an alpha animation when disapearing
136 if(timer.get_timeleft() < FADING_TIME)
137 alpha = int(timer.get_timeleft() * 255 / FADING_TIME);
141 context.push_transform();
142 context.set_alpha(alpha);
144 context.draw_text(gold_text, text, position, LEFT_ALLIGN, LAYER_OBJECTS+1);
146 context.pop_transform();
149 Sprite *img_smoke_cloud = 0;
151 SmokeCloud::SmokeCloud(const Vector& pos)
155 sprite = sprite_manager->create("images/objects/particles/stomp.sprite");
158 SmokeCloud::~SmokeCloud()
164 SmokeCloud::update(float elapsed_time)
166 position.y -= 120 * elapsed_time;
173 SmokeCloud::draw(DrawingContext& context)
175 sprite->draw(context, position, LAYER_OBJECTS+1);