2 // C Implementation: world
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
21 texture_type img_distro[4];
23 void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y)
25 pbouncy_distro->base.alive = YES;
26 pbouncy_distro->base.x = x;
27 pbouncy_distro->base.y = y;
28 pbouncy_distro->base.ym = -6;
31 void bouncy_distro_action(bouncy_distro_type* pbouncy_distro)
33 if (pbouncy_distro->base.alive)
35 pbouncy_distro->base.y = pbouncy_distro->base.y + pbouncy_distro->base.ym * frame_ratio;
37 pbouncy_distro->base.ym += 1. * frame_ratio;
39 if (pbouncy_distro->base.ym >= 0)
40 pbouncy_distro->base.alive = NO;
44 void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro)
46 if (pbouncy_distro->base.alive)
48 texture_draw(&img_distro[0],
49 pbouncy_distro->base.x - scroll_x,
50 pbouncy_distro->base.y,
55 void broken_brick_init(broken_brick_type* pbroken_brick, float x, float y, float xm, float ym)
57 pbroken_brick->base.alive = YES;
58 pbroken_brick->base.x = x;
59 pbroken_brick->base.y = y;
60 pbroken_brick->base.xm = xm;
61 pbroken_brick->base.ym = ym;
62 timer_start(&pbroken_brick->timer,200);
65 void broken_brick_action(broken_brick_type* pbroken_brick)
67 if (pbroken_brick->base.alive)
69 pbroken_brick->base.x = pbroken_brick->base.x + pbroken_brick->base.xm * frame_ratio;
70 pbroken_brick->base.y = pbroken_brick->base.y + pbroken_brick->base.ym * frame_ratio;
72 if (!timer_check(&pbroken_brick->timer))
73 pbroken_brick->base.alive = NO;
77 void broken_brick_draw(broken_brick_type* pbroken_brick)
80 if (pbroken_brick->base.alive)
87 dest.x = (int)(pbroken_brick->base.x - scroll_x);
88 dest.y = (int)pbroken_brick->base.y;
92 texture_draw_part(&img_brick[0],src.x,src.y,dest.x,dest.y,dest.w,dest.h,NO_UPDATE);
96 void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y)
98 pbouncy_brick->base.alive = YES;
99 pbouncy_brick->base.x = x;
100 pbouncy_brick->base.y = y;
101 pbouncy_brick->offset = 0;
102 pbouncy_brick->offset_m = -BOUNCY_BRICK_SPEED;
103 pbouncy_brick->shape = shape(x, y);
106 void bouncy_brick_action(bouncy_brick_type* pbouncy_brick)
109 if (pbouncy_brick->base.alive)
112 pbouncy_brick->offset = (pbouncy_brick->offset +
113 pbouncy_brick->offset_m * frame_ratio);
117 if (pbouncy_brick->offset < -BOUNCY_BRICK_MAX_OFFSET)
118 pbouncy_brick->offset_m = BOUNCY_BRICK_SPEED;
123 if (pbouncy_brick->offset >= 0)
124 pbouncy_brick->base.alive = NO;
128 void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick)
133 if (pbouncy_brick->base.alive)
135 if (pbouncy_brick->base.x >= scroll_x - 32 &&
136 pbouncy_brick->base.x <= scroll_x + screen->w)
138 dest.x = (int)(pbouncy_brick->base.x - scroll_x);
139 dest.y = (int)pbouncy_brick->base.y;
143 if(current_level.bkgd_image[0] == '\0')
145 fillrect(pbouncy_brick->base.x - scroll_x,pbouncy_brick->base.y,32,32,current_level.bkgd_red,current_level.bkgd_green,
146 current_level.bkgd_blue,0);
150 s = (int)scroll_x / 30;
151 texture_draw_part(&img_bkgd,dest.x + s,dest.y,dest.x,dest.y,dest.w,dest.h,NO_UPDATE);
154 drawshape(pbouncy_brick->base.x - scroll_x,
155 pbouncy_brick->base.y + pbouncy_brick->offset,
156 pbouncy_brick->shape);
161 void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s)
163 pfloating_score->base.alive = YES;
164 pfloating_score->base.x = x;
165 pfloating_score->base.y = y - 16;
166 timer_start(&pfloating_score->timer,1000);
167 pfloating_score->value = s;
170 void floating_score_action(floating_score_type* pfloating_score)
172 if (pfloating_score->base.alive)
174 pfloating_score->base.y = pfloating_score->base.y - 2 * frame_ratio;
176 if(!timer_check(&pfloating_score->timer))
177 pfloating_score->base.alive = NO;
181 void floating_score_draw(floating_score_type* pfloating_score)
183 if (pfloating_score->base.alive)
186 sprintf(str, "%d", pfloating_score->value);
187 text_draw(&gold_text, str, (int)pfloating_score->base.x + 16 - strlen(str) * 8, (int)pfloating_score->base.y, 1, NO_UPDATE);