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 texture_draw(&img_distro[0],
54 BrokenBrick::init(Tile* tile_, float x, float y, float xm, float ym)
67 BrokenBrick::action(double frame_ratio)
69 base.x = base.x + base.xm * frame_ratio;
70 base.y = base.y + base.ym * frame_ratio;
73 World::current()->broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
85 dest.x = (int)(base.x - scroll_x);
90 if (tile->images.size() > 0)
91 texture_draw_part(&tile->images[0],
92 src.x,src.y,dest.x,dest.y,dest.w,dest.h);
96 BouncyBrick::init(float x, float y)
101 offset_m = -BOUNCY_BRICK_SPEED;
102 shape = World::current()->get_level()->gettileid(x, y);
106 BouncyBrick::action(double frame_ratio)
108 offset = (offset + offset_m * frame_ratio);
111 if (offset < -BOUNCY_BRICK_MAX_OFFSET)
112 offset_m = BOUNCY_BRICK_SPEED;
117 World::current()->bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this));
126 if (base.x >= scroll_x - 32 &&
127 base.x <= scroll_x + screen->w)
129 dest.x = (int)(base.x - scroll_x);
130 dest.y = (int)base.y;
134 Level* plevel = World::current()->get_level();
136 // FIXME: overdrawing hack to clean the tile from the screen to
137 // paint it later at on offseted position
138 if(plevel->bkgd_image[0] == '\0')
140 fillrect(base.x - scroll_x, base.y,
142 plevel->bkgd_top_red, plevel->bkgd_top_green, plevel->bkgd_top_blue, 0);
143 // FIXME: doesn't respect the gradient, futhermore is this necessary at all??
147 s = (int)scroll_x / 30;
148 texture_draw_part(&plevel->img_bkgd, dest.x + s, dest.y,
149 dest.x, dest.y,dest.w,dest.h);
152 Tile::draw(base.x - scroll_x,
159 FloatingScore::init(float x, float y, int s)
169 FloatingScore::action(double frame_ratio)
171 base.y = base.y - 2 * frame_ratio;
174 World::current()->floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this));
178 FloatingScore::draw()
181 sprintf(str, "%d", value);
182 text_draw(&gold_text, str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);