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 bouncy_distro_type::init(float x, float y)
34 bouncy_distro_type::action()
36 base.y = base.y + base.ym * frame_ratio;
38 base.ym += 0.1 * frame_ratio;
41 world.bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(this));
45 bouncy_distro_type::draw()
47 texture_draw(&img_distro[0],
54 broken_brick_type::init(Tile* tile_, float x, float y, float xm, float ym)
62 timer_init(&timer, true);
63 timer_start(&timer,200);
67 broken_brick_type::action()
69 base.x = base.x + base.xm * frame_ratio;
70 base.y = base.y + base.ym * frame_ratio;
72 if (!timer_check(&timer))
73 world.broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(this));
77 broken_brick_type::draw()
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 bouncy_brick_type::init(float x, float y)
101 offset_m = -BOUNCY_BRICK_SPEED;
102 shape = World::current()->get_level()->gettileid(x, y);
106 bouncy_brick_type::action()
109 offset_m * frame_ratio);
112 if (offset < -BOUNCY_BRICK_MAX_OFFSET)
113 offset_m = BOUNCY_BRICK_SPEED;
118 world.bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(this));
122 bouncy_brick_type::draw()
127 if (base.x >= scroll_x - 32 &&
128 base.x <= scroll_x + screen->w)
130 dest.x = (int)(base.x - scroll_x);
131 dest.y = (int)base.y;
135 Level* plevel = World::current()->get_level();
137 // FIXME: overdrawing hack to clean the tile from the screen to
138 // paint it later at on offseted position
139 if(plevel->bkgd_image[0] == '\0')
141 fillrect(base.x - scroll_x, base.y,
143 plevel->bkgd_red, plevel->bkgd_green, plevel->bkgd_blue, 0);
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 floating_score_type::init(float x, float y, int s)
163 timer_init(&timer,true);
164 timer_start(&timer,1000);
169 floating_score_type::action()
171 base.y = base.y - 2 * frame_ratio;
173 if(!timer_check(&timer))
174 world.floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(this));
178 floating_score_type::draw()
181 sprintf(str, "%d", value);
182 text_draw(&gold_text, str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);