4 // Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details
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.
26 BouncyDistro::init(float x, float y)
34 BouncyDistro::action(double frame_ratio)
36 base.y = base.y + base.ym * frame_ratio;
38 base.ym += 0.1 * frame_ratio;
41 World::current()->bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this));
47 img_distro[0]->draw(base.x - scroll_x,
53 BrokenBrick::init(Tile* tile_, float x, float y, float xm, float ym)
66 BrokenBrick::action(double frame_ratio)
68 base.x = base.x + base.xm * frame_ratio;
69 base.y = base.y + base.ym * frame_ratio;
72 World::current()->broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
84 dest.x = (int)(base.x - scroll_x);
89 if (tile->images.size() > 0)
90 tile->images[0]->draw_part(src.x,src.y,dest.x,dest.y,dest.w,dest.h);
94 BouncyBrick::init(float x, float y)
99 offset_m = -BOUNCY_BRICK_SPEED;
100 shape = World::current()->get_level()->gettileid(x, y);
104 BouncyBrick::action(double frame_ratio)
106 offset = (offset + offset_m * frame_ratio);
109 if (offset < -BOUNCY_BRICK_MAX_OFFSET)
110 offset_m = BOUNCY_BRICK_SPEED;
115 World::current()->bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this));
124 if (base.x >= scroll_x - 32 &&
125 base.x <= scroll_x + screen->w)
127 dest.x = (int)(base.x - scroll_x);
128 dest.y = (int)base.y;
132 Level* plevel = World::current()->get_level();
134 // FIXME: overdrawing hack to clean the tile from the screen to
135 // paint it later at on offseted position
136 if(plevel->bkgd_image[0] == '\0')
138 fillrect(base.x - scroll_x, base.y,
140 plevel->bkgd_top.red, plevel->bkgd_top.green, plevel->bkgd_top.blue, 0);
141 // FIXME: doesn't respect the gradient, futhermore is this necessary at all??
145 s = (int)scroll_x / 30;
146 plevel->img_bkgd->draw_part(dest.x + s, dest.y,
147 dest.x, dest.y,dest.w,dest.h);
150 Tile::draw(base.x - scroll_x,
157 FloatingScore::init(float x, float y, int s)
167 FloatingScore::action(double frame_ratio)
169 base.y = base.y - 2 * frame_ratio;
172 World::current()->floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this));
176 FloatingScore::draw()
179 sprintf(str, "%d", value);
180 gold_text->draw(str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);