4 // Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
5 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 #include "sprite_manager.h"
27 #include "resources.h"
30 BouncyDistro::init(float x, float y)
38 BouncyDistro::action(double frame_ratio)
40 base.y = base.y + base.ym * frame_ratio;
42 base.ym += 0.1 * frame_ratio;
46 std::vector<BouncyDistro*>::iterator i
47 = std::find(World::current()->bouncy_distros.begin(),
48 World::current()->bouncy_distros.end(),
50 if (i != World::current()->bouncy_distros.end())
51 World::current()->bouncy_distros.erase(i);
58 img_distro[0]->draw(base.x - scroll_x,
64 BrokenBrick::init(Tile* tile_, float x, float y, float xm, float ym)
77 BrokenBrick::action(double frame_ratio)
79 base.x = base.x + base.xm * frame_ratio;
80 base.y = base.y + base.ym * frame_ratio;
84 std::vector<BrokenBrick*>::iterator i
85 = std::find(World::current()->broken_bricks.begin(),
86 World::current()->broken_bricks.end(),
88 if (i != World::current()->broken_bricks.end())
89 World::current()->broken_bricks.erase(i);
102 dest.x = (int)(base.x - scroll_x);
103 dest.y = (int)(base.y - scroll_y);
107 if (tile->images.size() > 0)
108 tile->images[0]->draw_part(src.x,src.y,dest.x,dest.y,dest.w,dest.h);
112 BouncyBrick::init(float x, float y)
117 offset_m = -BOUNCY_BRICK_SPEED;
118 shape = World::current()->get_level()->gettileid(x, y);
122 BouncyBrick::action(double frame_ratio)
124 offset = (offset + offset_m * frame_ratio);
127 if (offset < -BOUNCY_BRICK_MAX_OFFSET)
128 offset_m = BOUNCY_BRICK_SPEED;
134 std::vector<BouncyBrick*>::iterator i
135 = std::find(World::current()->bouncy_bricks.begin(),
136 World::current()->bouncy_bricks.end(),
138 if (i != World::current()->bouncy_bricks.end())
139 World::current()->bouncy_bricks.erase(i);
148 if (base.x >= scroll_x - 32 &&
149 base.x <= scroll_x + screen->w)
151 dest.x = (int)(base.x - scroll_x);
152 dest.y = (int)(base.y - scroll_y);
156 Level* plevel = World::current()->get_level();
158 // FIXME: overdrawing hack to clean the tile from the screen to
159 // paint it later at on offseted position
160 if(plevel->bkgd_image[0] == '\0')
162 fillrect(base.x - scroll_x, base.y - scroll_y,
164 plevel->bkgd_top.red, plevel->bkgd_top.green, plevel->bkgd_top.blue, 0);
165 // FIXME: doesn't respect the gradient, futhermore is this necessary at all??
169 int s = ((int)scroll_x / 2)%640;
170 plevel->img_bkgd->draw_part(dest.x + s, dest.y,
171 dest.x, dest.y,dest.w,dest.h);
174 Tile::draw(base.x - scroll_x,
175 base.y - scroll_y + offset,
181 FloatingScore::init(float x, float y, int s)
191 FloatingScore::action(double frame_ratio)
193 base.y = base.y - 2 * frame_ratio;
197 std::vector<FloatingScore*>::iterator i
198 = std::find(World::current()->floating_scores.begin(),
199 World::current()->floating_scores.end(),
201 if (i != World::current()->floating_scores.end())
202 World::current()->floating_scores.erase(i);
207 FloatingScore::draw()
210 sprintf(str, "%d", value);
211 gold_text->draw(str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);
216 #define TRAMPOLINE_FRAMES 4
217 Sprite *img_trampoline[TRAMPOLINE_FRAMES];
219 void load_trampoline_gfx()
221 for (int i = 0; i < TRAMPOLINE_FRAMES; i++)
223 char sprite_name[16];
224 sprintf(sprite_name, "trampoline-%i", i+1);
225 img_trampoline[0] = sprite_manager->load(sprite_name);
230 Trampoline::init(float x, float y)
237 Trampoline::action(double frame_ratio)
244 // - compress springs (reduce height)
250 img_trampoline[0]->draw((int)base.x, (int)base.y);