2 // C Implementation: world
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
22 void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y)
24 pbouncy_distro->base.alive = YES;
25 pbouncy_distro->base.x = x;
26 pbouncy_distro->base.y = y;
27 pbouncy_distro->base.ym = -6;
30 void bouncy_distro_action(bouncy_distro_type* pbouncy_distro)
32 if (pbouncy_distro->base.alive)
34 pbouncy_distro->base.y = pbouncy_distro->base.y + pbouncy_distro->base.ym;
36 pbouncy_distro->base.ym++;
38 if (pbouncy_distro->base.ym >= 0)
39 pbouncy_distro->base.alive = NO;
43 void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro)
45 if (pbouncy_distro->base.alive)
47 texture_draw(&img_distro[0],
48 pbouncy_distro->base.x - scroll_x,
49 pbouncy_distro->base.y,
54 void broken_brick_init(broken_brick_type* pbroken_brick, float x, float y, float xm, float ym)
56 pbroken_brick->base.alive = YES;
57 pbroken_brick->base.x = x;
58 pbroken_brick->base.y = y;
59 pbroken_brick->base.xm = xm;
60 pbroken_brick->base.ym = ym;
61 timer_start(&pbroken_brick->timer,200);
62 pbroken_brick->base.updated = SDL_GetTicks();
65 void broken_brick_action(broken_brick_type* pbroken_brick)
67 double frame_ratio = get_frame_ratio(&pbroken_brick->base);
69 if (pbroken_brick->base.alive)
71 pbroken_brick->base.x = pbroken_brick->base.x + pbroken_brick->base.xm * frame_ratio;
72 pbroken_brick->base.y = pbroken_brick->base.y + pbroken_brick->base.ym * frame_ratio;
74 if (!timer_check(&pbroken_brick->timer))
75 pbroken_brick->base.alive = NO;
79 void broken_brick_draw(broken_brick_type* pbroken_brick)
81 if (pbroken_brick->base.alive)
88 dest.x = pbroken_brick->base.x - scroll_x;
89 dest.y = pbroken_brick->base.y;
93 SDL_BlitSurface(img_brick[0].sdl_surface, &src, screen, &dest);
97 void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y)
99 pbouncy_brick->base.alive = YES;
100 pbouncy_brick->base.x = x;
101 pbouncy_brick->base.y = y;
102 pbouncy_brick->offset = 0;
103 pbouncy_brick->offset_m = -BOUNCY_BRICK_SPEED;
104 pbouncy_brick->shape = shape(x, y);
105 pbouncy_brick->base.updated = SDL_GetTicks();
108 void bouncy_brick_action(bouncy_brick_type* pbouncy_brick)
111 double frame_ratio = get_frame_ratio(&pbouncy_brick->base);
113 if (pbouncy_brick->base.alive)
116 pbouncy_brick->offset = (pbouncy_brick->offset +
117 pbouncy_brick->offset_m * frame_ratio);
121 if (pbouncy_brick->offset < -BOUNCY_BRICK_MAX_OFFSET)
122 pbouncy_brick->offset_m = BOUNCY_BRICK_SPEED;
127 if (pbouncy_brick->offset >= 0)
128 pbouncy_brick->base.alive = NO;
132 void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick)
134 if (pbouncy_brick->base.alive)
136 if (pbouncy_brick->base.x >= scroll_x - 32 &&
137 pbouncy_brick->base.x <= scroll_x + screen->w)
139 dest.x = pbouncy_brick->base.x - scroll_x;
140 dest.y = pbouncy_brick->base.y;
144 SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format,
145 current_level.bkgd_red,
146 current_level.bkgd_green,
147 current_level.bkgd_blue));
149 drawshape(pbouncy_brick->base.x - scroll_x,
150 pbouncy_brick->base.y + pbouncy_brick->offset,
151 pbouncy_brick->shape);
156 void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s)
158 pfloating_score->base.alive = YES;
159 pfloating_score->base.x = x;
160 pfloating_score->base.y = y - 16;
161 timer_start(&pfloating_score->timer,1000);
162 pfloating_score->value = s;
163 pfloating_score->base.updated = SDL_GetTicks();
167 void floating_score_action(floating_score_type* pfloating_score)
169 double frame_ratio = get_frame_ratio(&pfloating_score->base);
171 if (pfloating_score->base.alive)
173 pfloating_score->base.y = pfloating_score->base.y - 2 * frame_ratio;
175 if(!timer_check(&pfloating_score->timer))
176 pfloating_score->base.alive = NO;
180 void floating_score_draw(floating_score_type* pfloating_score)
182 if (pfloating_score->base.alive)
185 sprintf(str, "%d", pfloating_score->value);
187 pfloating_score->base.x + 16 - strlen(str) * 8,
188 pfloating_score->base.y,
189 letters_gold, NO_UPDATE, 1);