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
28 BouncyDistro::init(float x, float y)
36 BouncyDistro::action(double frame_ratio)
38 base.y = base.y + base.ym * frame_ratio;
40 base.ym += 0.1 * frame_ratio;
44 std::vector<BouncyDistro*>::iterator i
45 = std::find(World::current()->bouncy_distros.begin(),
46 World::current()->bouncy_distros.end(),
48 if (i != World::current()->bouncy_distros.end())
49 World::current()->bouncy_distros.erase(i);
56 img_distro[0]->draw(base.x - scroll_x,
62 BrokenBrick::init(Tile* tile_, float x, float y, float xm, float ym)
75 BrokenBrick::action(double frame_ratio)
77 base.x = base.x + base.xm * frame_ratio;
78 base.y = base.y + base.ym * frame_ratio;
82 std::vector<BrokenBrick*>::iterator i
83 = std::find(World::current()->broken_bricks.begin(),
84 World::current()->broken_bricks.end(),
86 if (i != World::current()->broken_bricks.end())
87 World::current()->broken_bricks.erase(i);
100 dest.x = (int)(base.x - scroll_x);
101 dest.y = (int)base.y;
105 if (tile->images.size() > 0)
106 tile->images[0]->draw_part(src.x,src.y,dest.x,dest.y,dest.w,dest.h);
110 BouncyBrick::init(float x, float y)
115 offset_m = -BOUNCY_BRICK_SPEED;
116 shape = World::current()->get_level()->gettileid(x, y);
120 BouncyBrick::action(double frame_ratio)
122 offset = (offset + offset_m * frame_ratio);
125 if (offset < -BOUNCY_BRICK_MAX_OFFSET)
126 offset_m = BOUNCY_BRICK_SPEED;
132 std::vector<BouncyBrick*>::iterator i
133 = std::find(World::current()->bouncy_bricks.begin(),
134 World::current()->bouncy_bricks.end(),
136 if (i != World::current()->bouncy_bricks.end())
137 World::current()->bouncy_bricks.erase(i);
146 if (base.x >= scroll_x - 32 &&
147 base.x <= scroll_x + screen->w)
149 dest.x = (int)(base.x - scroll_x);
150 dest.y = (int)base.y;
154 Level* plevel = World::current()->get_level();
156 // FIXME: overdrawing hack to clean the tile from the screen to
157 // paint it later at on offseted position
158 if(plevel->bkgd_image[0] == '\0')
160 fillrect(base.x - scroll_x, base.y,
162 plevel->bkgd_top.red, plevel->bkgd_top.green, plevel->bkgd_top.blue, 0);
163 // FIXME: doesn't respect the gradient, futhermore is this necessary at all??
167 int s = ((int)scroll_x / 2)%640;
168 plevel->img_bkgd->draw_part(dest.x + s, dest.y,
169 dest.x, dest.y,dest.w,dest.h);
172 Tile::draw(base.x - scroll_x,
179 FloatingScore::init(float x, float y, int s)
189 FloatingScore::action(double frame_ratio)
191 base.y = base.y - 2 * frame_ratio;
195 std::vector<FloatingScore*>::iterator i
196 = std::find(World::current()->floating_scores.begin(),
197 World::current()->floating_scores.end(),
199 if (i != World::current()->floating_scores.end())
200 World::current()->floating_scores.erase(i);
205 FloatingScore::draw()
208 sprintf(str, "%d", value);
209 gold_text->draw(str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);