diff options
author | Zakk Roberts <midk@rockbox.org> | 2007-01-01 23:31:53 +0000 |
---|---|---|
committer | Zakk Roberts <midk@rockbox.org> | 2007-01-01 23:31:53 +0000 |
commit | f8fcbafd129a6f56730f59e6ef2a63a521929e41 (patch) | |
tree | 850b418ccc9a3dd1f196428092fba5be25ab6397 /apps/plugins/spacerocks.c | |
parent | ec529a155627a6541ca314f7e61660cdb87e630b (diff) | |
download | rockbox-f8fcbafd129a6f56730f59e6ef2a63a521929e41.tar.gz rockbox-f8fcbafd129a6f56730f59e6ef2a63a521929e41.zip |
Patch #5916 by Mat Holton - some Spacerocks improvements. Larger ship and asteroids, fixed collision detection bug, ship thruster effect and improved explosion effect.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11881 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/spacerocks.c')
-rwxr-xr-x | apps/plugins/spacerocks.c | 572 |
1 files changed, 410 insertions, 162 deletions
diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c index 231772f76d..673c931810 100755 --- a/apps/plugins/spacerocks.c +++ b/apps/plugins/spacerocks.c | |||
@@ -134,21 +134,13 @@ static struct plugin_api* rb; /* global api struct pointer */ | |||
134 | 134 | ||
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | #define SHOW_COL 0 | ||
138 | #define HISCORE_FILE PLUGIN_DIR "/astrorocks.hs" | ||
139 | #define POINT_SIZE 2 | ||
140 | #define MAX_NUM_ASTEROIDS 25 | ||
141 | #define MAX_NUM_MISSILES 6 | ||
142 | #define ABS(x) ((x)>0?(x):-(x)) | 137 | #define ABS(x) ((x)>0?(x):-(x)) |
143 | 138 | ||
144 | #define SCALE 5000 | ||
145 | #define MISSILE_SCALE 5000 | ||
146 | #define WRAP_GAP 12 | ||
147 | #define EXPLOSION_LENGTH 35 | ||
148 | |||
149 | #if CONFIG_KEYPAD == RECORDER_PAD || CONFIG_KEYPAD == ONDIO_PAD | 139 | #if CONFIG_KEYPAD == RECORDER_PAD || CONFIG_KEYPAD == ONDIO_PAD |
150 | #define ENEMY_MISSILE_SURVIVAL_LENGTH 65 | 140 | #define ENEMY_MISSILE_SURVIVAL_LENGTH 65 |
151 | #define MISSILE_SURVIVAL_LENGTH 40 | 141 | #define MISSILE_SURVIVAL_LENGTH 40 |
142 | #define ASTEROID_SPEED 5 | ||
143 | #define LARGE_LCD 0 | ||
152 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ | 144 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ |
153 | (CONFIG_KEYPAD == IRIVER_H300_PAD) || \ | 145 | (CONFIG_KEYPAD == IRIVER_H300_PAD) || \ |
154 | (CONFIG_KEYPAD == IAUDIO_X5_PAD) || \ | 146 | (CONFIG_KEYPAD == IAUDIO_X5_PAD) || \ |
@@ -156,10 +148,27 @@ static struct plugin_api* rb; /* global api struct pointer */ | |||
156 | (CONFIG_KEYPAD == IPOD_4G_PAD) || \ | 148 | (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
157 | (CONFIG_KEYPAD == GIGABEAT_PAD)|| \ | 149 | (CONFIG_KEYPAD == GIGABEAT_PAD)|| \ |
158 | (CONFIG_KEYPAD == IRIVER_H10_PAD) | 150 | (CONFIG_KEYPAD == IRIVER_H10_PAD) |
159 | #define ENEMY_MISSILE_SURVIVAL_LENGTH 120 | 151 | #define ENEMY_MISSILE_SURVIVAL_LENGTH 140 |
160 | #define MISSILE_SURVIVAL_LENGTH 80 | 152 | #define MISSILE_SURVIVAL_LENGTH 40 |
153 | #define ASTEROID_SPEED 15 | ||
154 | #define LARGE_LCD 1 | ||
161 | #endif | 155 | #endif |
162 | 156 | ||
157 | #define EXTRA_LIFE 250 | ||
158 | #define SCALE 5000 | ||
159 | #define MISSILE_SCALE 5000 | ||
160 | #define WRAP_GAP 12 | ||
161 | #define EXPLOSION_LENGTH 20 | ||
162 | #define SHOW_COL 0 | ||
163 | #define HISCORE_FILE PLUGIN_DIR "/astrorocks.hs" | ||
164 | #define POINT_SIZE 2 | ||
165 | #define MAX_NUM_ASTEROIDS 25 | ||
166 | #define MAX_NUM_MISSILES 6 | ||
167 | #define ENEMY_BIG_PROBABILITY_START 10 | ||
168 | #define ENEMY_APPEAR_PROBABILITY_START 35 | ||
169 | #define ENEMY_APPEAR_TIMING_START 1800 | ||
170 | #define LITTLE_SHIP 2 | ||
171 | #define BIG_SHIP 1 | ||
163 | #define SHOW_GAME_OVER_TIME 100 | 172 | #define SHOW_GAME_OVER_TIME 100 |
164 | #define SHOW_LEVEL_TIME 50 | 173 | #define SHOW_LEVEL_TIME 50 |
165 | #define START_LIVES 3 | 174 | #define START_LIVES 3 |
@@ -174,13 +183,10 @@ static struct plugin_api* rb; /* global api struct pointer */ | |||
174 | #define SIZE_ENEMY_COLLISION 5*SCALE | 183 | #define SIZE_ENEMY_COLLISION 5*SCALE |
175 | #define ATTRACT_FLIP_TIME 100 | 184 | #define ATTRACT_FLIP_TIME 100 |
176 | #define NUM_STARS 50 | 185 | #define NUM_STARS 50 |
186 | #define NUM_TRAIL_POINTS 70 | ||
177 | #define NUM_ROTATIONS 16 | 187 | #define NUM_ROTATIONS 16 |
178 | 188 | ||
179 | #define SIN_COS_SCALE 10000 | 189 | #define SIN_COS_SCALE 10000 |
180 | #define SHIP_ROT_CW_SIN 3827 | ||
181 | #define SHIP_ROT_CW_COS 9239 | ||
182 | #define SHIP_ROT_ACW_SIN -3827 | ||
183 | #define SHIP_ROT_ACW_COS 9239 | ||
184 | 190 | ||
185 | #define FAST_ROT_CW_SIN 873 | 191 | #define FAST_ROT_CW_SIN 873 |
186 | #define FAST_ROT_CW_COS 9963 | 192 | #define FAST_ROT_CW_COS 9963 |
@@ -197,18 +203,49 @@ static struct plugin_api* rb; /* global api struct pointer */ | |||
197 | #define SLOW_ROT_ACW_SIN - 350 | 203 | #define SLOW_ROT_ACW_SIN - 350 |
198 | #define SLOW_ROT_ACW_COS 9994 | 204 | #define SLOW_ROT_ACW_COS 9994 |
199 | 205 | ||
206 | #ifdef HAVE_LCD_COLOR | ||
207 | #define SHIP_ROT_CW_SIN 2419 | ||
208 | #define SHIP_ROT_CW_COS 9702 | ||
209 | #define SHIP_ROT_ACW_SIN -2419 | ||
210 | #define SHIP_ROT_ACW_COS 9702 | ||
211 | #else | ||
212 | #define SHIP_ROT_CW_SIN 3827 | ||
213 | #define SHIP_ROT_CW_COS 9239 | ||
214 | #define SHIP_ROT_ACW_SIN -3827 | ||
215 | #define SHIP_ROT_ACW_COS 9239 | ||
216 | #endif | ||
217 | |||
218 | |||
200 | #define SCALED_WIDTH (LCD_WIDTH*SCALE) | 219 | #define SCALED_WIDTH (LCD_WIDTH*SCALE) |
201 | #define SCALED_HEIGHT (LCD_HEIGHT*SCALE) | 220 | #define SCALED_HEIGHT (LCD_HEIGHT*SCALE) |
202 | #define CENTER_LCD_X (LCD_WIDTH/2) | 221 | #define CENTER_LCD_X (LCD_WIDTH/2) |
203 | #define CENTER_LCD_Y (LCD_HEIGHT/2) | 222 | #define CENTER_LCD_Y (LCD_HEIGHT/2) |
204 | 223 | ||
224 | #define SHIP_EXPLOSION_COLOUR 1 | ||
225 | #define ASTEROID_EXPLOSION_COLOUR 2 | ||
226 | #define ENEMY_EXPLOSION_COLOUR 3 | ||
227 | #define THRUST_COLOUR 4 | ||
228 | |||
229 | #define ASTEROID_R 230 | ||
230 | #define ASTEROID_G 200 | ||
231 | #define ASTEROID_B 100 | ||
232 | #define SHIP_R 255 | ||
233 | #define SHIP_G 255 | ||
234 | #define SHIP_B 255 | ||
235 | #define ENEMY_R 50 | ||
236 | #define ENEMY_G 220 | ||
237 | #define ENEMY_B 50 | ||
238 | #define THRUST_R 200 | ||
239 | #define THRUST_G 200 | ||
240 | #define THRUST_B 0 | ||
241 | |||
205 | #ifdef HAVE_LCD_COLOR | 242 | #ifdef HAVE_LCD_COLOR |
206 | #define COL_MISSILE LCD_RGBPACK(200,0,0) | 243 | #define COL_MISSILE LCD_RGBPACK(200,0,0) |
207 | #define COL_PLAYER LCD_RGBPACK(200,200,200) | 244 | #define COL_PLAYER LCD_RGBPACK(200,200,200) |
208 | #define COL_STARS LCD_WHITE | 245 | #define COL_STARS LCD_WHITE |
209 | #define COL_ASTEROID LCD_RGBPACK(150,95,0) | 246 | #define COL_ASTEROID LCD_RGBPACK(ASTEROID_R,ASTEROID_G,ASTEROID_B) |
210 | #define COL_TEXT LCD_RGBPACK(200,200,255) | 247 | #define COL_TEXT LCD_RGBPACK(200,200,255) |
211 | #define COL_ENEMY LCD_RGBPACK(50,220,50) | 248 | #define COL_ENEMY LCD_RGBPACK(ENEMY_R,ENEMY_G,ENEMY_B) |
212 | #define SET_FG rb->lcd_set_foreground | 249 | #define SET_FG rb->lcd_set_foreground |
213 | #define SET_BG rb->lcd_set_background | 250 | #define SET_BG rb->lcd_set_background |
214 | #else | 251 | #else |
@@ -216,11 +253,100 @@ static struct plugin_api* rb; /* global api struct pointer */ | |||
216 | #define SET_BG(x) | 253 | #define SET_BG(x) |
217 | #endif | 254 | #endif |
218 | 255 | ||
256 | /* The array of points that make up an asteroid */ | ||
257 | static const short asteroid_one[NUM_ASTEROID_VERTICES*2] = | ||
258 | { | ||
259 | -2, -12, | ||
260 | 4, -8, | ||
261 | 8, -14, | ||
262 | 16, -5, | ||
263 | 14, 0, | ||
264 | 20, 2, | ||
265 | 12, 14, | ||
266 | -4, 14, | ||
267 | -10, 6, | ||
268 | -10, -8 | ||
269 | }; | ||
270 | |||
271 | /* The array of points that make up an asteroid */ | ||
272 | static const short asteroid_two[NUM_ASTEROID_VERTICES*2] = | ||
273 | { | ||
274 | -2, -12, | ||
275 | 4, -16, | ||
276 | 6, -14, | ||
277 | 16, -8, | ||
278 | 14, 0, | ||
279 | 20, 2, | ||
280 | 12, 14, | ||
281 | -4, 14, | ||
282 | -10, 6, | ||
283 | -10, -8 | ||
284 | }; | ||
285 | |||
286 | /* The array of points that make up an asteroid */ | ||
287 | static const short asteroid_three[NUM_ASTEROID_VERTICES*2] = | ||
288 | { | ||
289 | -2, -12, | ||
290 | 4, -16, | ||
291 | 6, -14, | ||
292 | 2, -8, | ||
293 | 14, 0, | ||
294 | 20, 2, | ||
295 | 12, 14, | ||
296 | -4, 14, | ||
297 | -16, 6, | ||
298 | -10, -8 | ||
299 | }; | ||
300 | |||
301 | /* The array od points the make up the ship */ | ||
302 | static const short ship_vertices[NUM_SHIP_VERTICES*2] = | ||
303 | { | ||
304 | #if(LARGE_LCD) | ||
305 | 0,-6, | ||
306 | 4, 6, | ||
307 | 0, 2, | ||
308 | -4, 6 | ||
309 | #else | ||
310 | 0,-4, | ||
311 | 3, 4, | ||
312 | 0, 1, | ||
313 | -3, 4 | ||
314 | #endif | ||
315 | }; | ||
316 | |||
317 | /* The array of points the make up the bad spaceship */ | ||
318 | static const short enemy_vertices[NUM_ENEMY_VERTICES*2] = | ||
319 | { | ||
320 | #if(LARGE_LCD) | ||
321 | -8, 0, | ||
322 | -4, 4, | ||
323 | 4, 4, | ||
324 | 8, 0, | ||
325 | 4, -4, | ||
326 | -4, -4 | ||
327 | #else | ||
328 | -5, 0, | ||
329 | -2, 2, | ||
330 | 2, 2, | ||
331 | 5, 0, | ||
332 | 2, -2, | ||
333 | -2, -2 | ||
334 | #endif | ||
335 | |||
336 | }; | ||
337 | |||
219 | enum asteroid_type | 338 | enum asteroid_type |
220 | { | 339 | { |
340 | #if(LARGE_LCD) | ||
341 | SMALL = 2, | ||
342 | MEDIUM = 4, | ||
343 | LARGE = 6, | ||
344 | #else | ||
221 | SMALL = 1, | 345 | SMALL = 1, |
222 | MEDIUM = 2, | 346 | MEDIUM = 2, |
223 | LARGE = 3, | 347 | LARGE = 3, |
348 | #endif | ||
349 | |||
224 | }; | 350 | }; |
225 | 351 | ||
226 | enum game_state | 352 | enum game_state |
@@ -240,6 +366,16 @@ struct Point | |||
240 | int dy; | 366 | int dy; |
241 | }; | 367 | }; |
242 | 368 | ||
369 | struct TrailPoint | ||
370 | { | ||
371 | int alive; | ||
372 | struct Point position; | ||
373 | short r; | ||
374 | short g; | ||
375 | short b; | ||
376 | short dec; | ||
377 | }; | ||
378 | |||
243 | /* Asteroid structure, contains an array of points */ | 379 | /* Asteroid structure, contains an array of points */ |
244 | struct Asteroid | 380 | struct Asteroid |
245 | { | 381 | { |
@@ -266,6 +402,10 @@ struct Enemy | |||
266 | struct Point vertices[NUM_ENEMY_VERTICES]; | 402 | struct Point vertices[NUM_ENEMY_VERTICES]; |
267 | struct Point position; | 403 | struct Point position; |
268 | int explode_countdown; | 404 | int explode_countdown; |
405 | long last_time_appeared; | ||
406 | short size_probability; | ||
407 | short appear_probability; | ||
408 | short appear_timing; | ||
269 | }; | 409 | }; |
270 | 410 | ||
271 | struct Missile | 411 | struct Missile |
@@ -280,13 +420,14 @@ static int asteroid_count; | |||
280 | static int next_missile_count; | 420 | static int next_missile_count; |
281 | static int next_thrust_count; | 421 | static int next_thrust_count; |
282 | static int num_lives; | 422 | static int num_lives; |
423 | static int extra_life; | ||
283 | static int show_level_timeout; | 424 | static int show_level_timeout; |
284 | static int attract_flip_timeout; | 425 | static int attract_flip_timeout; |
285 | static int show_game_over; | 426 | static int show_game_over; |
286 | static int current_level; | 427 | static int current_level; |
287 | static int current_score; | 428 | static int current_score; |
288 | static int high_score; | 429 | static int high_score; |
289 | static int space_check_size = 20*SCALE; | 430 | static int space_check_size = 30*SCALE; |
290 | 431 | ||
291 | static bool enemy_on_screen; | 432 | static bool enemy_on_screen; |
292 | static char phscore[30]; | 433 | static char phscore[30]; |
@@ -297,6 +438,7 @@ static struct Missile missiles_array[MAX_NUM_MISSILES]; | |||
297 | static struct Missile enemy_missile; | 438 | static struct Missile enemy_missile; |
298 | static struct Enemy enemy; | 439 | static struct Enemy enemy; |
299 | static struct Point lives_points[NUM_SHIP_VERTICES]; | 440 | static struct Point lives_points[NUM_SHIP_VERTICES]; |
441 | static struct TrailPoint trailPoints[NUM_TRAIL_POINTS]; | ||
300 | 442 | ||
301 | void draw_and_move_asteroids(void); | 443 | void draw_and_move_asteroids(void); |
302 | void initialise_game(int nStartNum); | 444 | void initialise_game(int nStartNum); |
@@ -331,70 +473,7 @@ void draw_lives(void); | |||
331 | void drawstars(void); | 473 | void drawstars(void); |
332 | bool is_ship_within_asteroid(struct Asteroid* asteroid); | 474 | bool is_ship_within_asteroid(struct Asteroid* asteroid); |
333 | 475 | ||
334 | /* The array of points that make up an asteroid */ | ||
335 | static const short asteroid_one[NUM_ASTEROID_VERTICES*2] = | ||
336 | { | ||
337 | -1, -6, | ||
338 | 2, -4, | ||
339 | 4, -7, | ||
340 | 8, -4, | ||
341 | 7, 0, | ||
342 | 10, 1, | ||
343 | 6, 7, | ||
344 | -2, 7, | ||
345 | -5, 3, | ||
346 | -5, -4 | ||
347 | }; | ||
348 | 476 | ||
349 | /* The array of points that make up an asteroid */ | ||
350 | static const short asteroid_two[NUM_ASTEROID_VERTICES*2] = | ||
351 | { | ||
352 | -1, -6, | ||
353 | 2, -8, | ||
354 | 3, -7, | ||
355 | 8, -4, | ||
356 | 7, 0, | ||
357 | 10, 1, | ||
358 | 6, 7, | ||
359 | -2, 7, | ||
360 | -5, 3, | ||
361 | -5, -4 | ||
362 | }; | ||
363 | |||
364 | /* The array of points that make up an asteroid */ | ||
365 | static const short asteroid_three[NUM_ASTEROID_VERTICES*2] = | ||
366 | { | ||
367 | -1, -6, | ||
368 | 2, -8, | ||
369 | 3, -7, | ||
370 | 1, -4, | ||
371 | 7, 0, | ||
372 | 10, 1, | ||
373 | 6, 7, | ||
374 | -2, 7, | ||
375 | -8, 3, | ||
376 | -5, -4 | ||
377 | }; | ||
378 | |||
379 | /* The array od points the make up the ship */ | ||
380 | static const short ship_vertices[NUM_SHIP_VERTICES*2] = | ||
381 | { | ||
382 | 0,-4, | ||
383 | 3, 4, | ||
384 | 0, 1, | ||
385 | -3, 4 | ||
386 | }; | ||
387 | |||
388 | /* The array of points the make up the bad spaceship */ | ||
389 | static const short enemy_vertices[NUM_ENEMY_VERTICES*2] = | ||
390 | { | ||
391 | -5, 0, | ||
392 | -2, 2, | ||
393 | 2, 2, | ||
394 | 5, 0, | ||
395 | 2, -2, | ||
396 | -2, -2 | ||
397 | }; | ||
398 | 477 | ||
399 | /*Hi-Score reading and writing to file - this needs moving to the hi-score plugin lib as | 478 | /*Hi-Score reading and writing to file - this needs moving to the hi-score plugin lib as |
400 | a 3rd function */ | 479 | a 3rd function */ |
@@ -471,6 +550,131 @@ void move_point(struct Point* point) | |||
471 | point->y = SCALED_HEIGHT; | 550 | point->y = SCALED_HEIGHT; |
472 | } | 551 | } |
473 | 552 | ||
553 | void create_trail(struct TrailPoint* tpoint) | ||
554 | { | ||
555 | tpoint->position.dx = -( ship.vertices[0].x - ship.vertices[2].x )/10; | ||
556 | tpoint->position.dy = -( ship.vertices[0].y - ship.vertices[2].y )/10; | ||
557 | } | ||
558 | |||
559 | void create_explosion_trail(struct TrailPoint* tpoint) | ||
560 | { | ||
561 | tpoint->position.dx = (rb->rand()%5050)-2500; | ||
562 | tpoint->position.dy = (rb->rand()%5050)-2500; | ||
563 | } | ||
564 | |||
565 | void create_trail_blaze(int colour, struct Point* position) | ||
566 | { | ||
567 | int numtoadd; | ||
568 | struct TrailPoint* tpoint; | ||
569 | int n; | ||
570 | int xadd,yadd; | ||
571 | if(colour != SHIP_EXPLOSION_COLOUR) | ||
572 | { | ||
573 | numtoadd = NUM_TRAIL_POINTS/5; | ||
574 | xadd = position->x; | ||
575 | yadd = position->y; | ||
576 | } | ||
577 | else | ||
578 | { | ||
579 | numtoadd = NUM_TRAIL_POINTS/8; | ||
580 | xadd = ship.position.x; | ||
581 | yadd = ship.position.y; | ||
582 | } | ||
583 | |||
584 | //give the point a random countdown timer, so they dissapears at different times | ||
585 | tpoint = trailPoints; | ||
586 | n = NUM_TRAIL_POINTS; | ||
587 | while(--n) | ||
588 | { | ||
589 | if(tpoint->alive <= 0 && numtoadd) | ||
590 | { | ||
591 | numtoadd--; | ||
592 | //take a random x point anywhere between | ||
593 | //bottom two points of ship. | ||
594 | tpoint->position.x = (ship.vertices[2].x + (rb->rand()%18000)-9000) + position->x; //ship.position.x; | ||
595 | tpoint->position.y = (ship.vertices[2].y + (rb->rand()%18000)-9000) + position->y; | ||
596 | |||
597 | switch(colour) | ||
598 | { | ||
599 | case SHIP_EXPLOSION_COLOUR: | ||
600 | tpoint->r = 255; | ||
601 | tpoint->g = 255; | ||
602 | tpoint->b = 255; | ||
603 | create_explosion_trail(tpoint); | ||
604 | tpoint->alive = 510; | ||
605 | tpoint->dec = 2; | ||
606 | break; | ||
607 | case ASTEROID_EXPLOSION_COLOUR: | ||
608 | tpoint->r = ASTEROID_R; | ||
609 | tpoint->g = ASTEROID_G; | ||
610 | tpoint->b = ASTEROID_B; | ||
611 | create_explosion_trail(tpoint); | ||
612 | tpoint->alive = 510; | ||
613 | tpoint->dec = 2; | ||
614 | break; | ||
615 | case ENEMY_EXPLOSION_COLOUR: | ||
616 | tpoint->r = ENEMY_R; | ||
617 | tpoint->g = ENEMY_G; | ||
618 | tpoint->b = ENEMY_B; | ||
619 | create_explosion_trail(tpoint); | ||
620 | tpoint->alive = 510; | ||
621 | tpoint->dec = 2; | ||
622 | break; | ||
623 | case THRUST_COLOUR: | ||
624 | tpoint->r = THRUST_R; | ||
625 | tpoint->g = THRUST_G; | ||
626 | tpoint->b = THRUST_B; | ||
627 | create_trail(tpoint); | ||
628 | tpoint->alive = 175; | ||
629 | tpoint->dec = 4; | ||
630 | break; | ||
631 | } | ||
632 | //add a proportional bit to the x and y based on dx and dy | ||
633 | |||
634 | //give the points a speed based on direction of travel - i.e. opposite | ||
635 | tpoint->position.dx += position->dx; | ||
636 | tpoint->position.dy += position->dy; | ||
637 | |||
638 | |||
639 | } | ||
640 | tpoint++; | ||
641 | } | ||
642 | //find a space in the array of trail_points that is NULL or DEAD or whatever. | ||
643 | //and place this one here. | ||
644 | |||
645 | } | ||
646 | |||
647 | void draw_trail_blaze(void) | ||
648 | { | ||
649 | struct TrailPoint* tpoint; | ||
650 | //loop through, if alive then move and draw. | ||
651 | //when drawn, countdown it's timer. | ||
652 | //if zero kill it! | ||
653 | tpoint = trailPoints; | ||
654 | int n = NUM_TRAIL_POINTS; | ||
655 | |||
656 | while(--n) | ||
657 | { | ||
658 | if(tpoint->alive) | ||
659 | { | ||
660 | if(game_state != PAUSE_MODE) | ||
661 | { | ||
662 | tpoint->alive-=10; | ||
663 | move_point(&(tpoint->position)); | ||
664 | } | ||
665 | #ifdef HAVE_LCD_COLOR | ||
666 | //intensity = tpoint->alive/2; | ||
667 | if(tpoint->r>0)tpoint->r-=tpoint->dec; | ||
668 | if(tpoint->g>0)tpoint->g-=tpoint->dec; | ||
669 | if(tpoint->b>0)tpoint->b-=tpoint->dec; | ||
670 | SET_FG(LCD_RGBPACK(tpoint->r, tpoint->g, tpoint->b)); | ||
671 | #endif | ||
672 | rb->lcd_drawpixel(tpoint->position.x/SCALE , tpoint->position.y/SCALE); | ||
673 | } | ||
674 | tpoint++; | ||
675 | } | ||
676 | } | ||
677 | |||
474 | /*Check if point is within a rectangle*/ | 678 | /*Check if point is within a rectangle*/ |
475 | bool is_point_within_rectangle(struct Point* rect, struct Point* p, int size) | 679 | bool is_point_within_rectangle(struct Point* rect, struct Point* p, int size) |
476 | { | 680 | { |
@@ -561,18 +765,33 @@ void initialise_enemy(void) | |||
561 | { | 765 | { |
562 | struct Point* point; | 766 | struct Point* point; |
563 | int n; | 767 | int n; |
768 | int size; | ||
769 | |||
770 | if(rb->rand()%100 > enemy.size_probability) | ||
771 | { | ||
772 | size = BIG_SHIP; | ||
773 | enemy.size_probability++; | ||
774 | if(enemy.size_probability < 90) | ||
775 | { | ||
776 | enemy.size_probability = ENEMY_BIG_PROBABILITY_START; | ||
777 | } | ||
778 | } | ||
779 | else | ||
780 | { | ||
781 | size = LITTLE_SHIP; | ||
782 | } | ||
564 | 783 | ||
565 | enemy_missile.survived = 0; | 784 | enemy_missile.survived = 0; |
566 | enemy_on_screen = true; | 785 | enemy_on_screen = true; |
567 | enemy.explode_countdown = 0; | 786 | enemy.explode_countdown = 0; |
568 | 787 | enemy.last_time_appeared = *rb->current_tick; | |
569 | point = enemy.vertices; | 788 | point = enemy.vertices; |
570 | for(n = 0; n < NUM_ENEMY_VERTICES+NUM_ENEMY_VERTICES; n+=2) | 789 | for(n = 0; n < NUM_ENEMY_VERTICES+NUM_ENEMY_VERTICES; n+=2) |
571 | { | 790 | { |
572 | point->x = enemy_vertices[n]; | 791 | point->x = enemy_vertices[n]; |
573 | point->y = enemy_vertices[n+1]; | 792 | point->y = enemy_vertices[n+1]; |
574 | point->x *= SCALE; | 793 | point->x *= SCALE/size; |
575 | point->y *= SCALE; | 794 | point->y *= SCALE/size; |
576 | point++; | 795 | point++; |
577 | } | 796 | } |
578 | 797 | ||
@@ -619,7 +838,7 @@ void draw_and_move_enemy(void) | |||
619 | draw_polygon(enemy.vertices, enemy_x, enemy_y, NUM_ENEMY_VERTICES); | 838 | draw_polygon(enemy.vertices, enemy_x, enemy_y, NUM_ENEMY_VERTICES); |
620 | rb->lcd_drawline(enemy.vertices[0].x/SCALE + enemy_x, | 839 | rb->lcd_drawline(enemy.vertices[0].x/SCALE + enemy_x, |
621 | enemy.vertices[0].y/SCALE + enemy_y, | 840 | enemy.vertices[0].y/SCALE + enemy_y, |
622 | enemy.vertices[3].x/SCALE + enemy_x, | 841 | enemy.vertices[3].x/SCALE + enemy_x, |
623 | enemy.vertices[3].y/SCALE + enemy_y); | 842 | enemy.vertices[3].y/SCALE + enemy_y); |
624 | 843 | ||
625 | if(game_state != PAUSE_MODE) | 844 | if(game_state != PAUSE_MODE) |
@@ -642,8 +861,8 @@ void draw_and_move_enemy(void) | |||
642 | else | 861 | else |
643 | { | 862 | { |
644 | 863 | ||
645 | animate_and_draw_explosion(enemy.vertices, NUM_ENEMY_VERTICES, | 864 | //animate_and_draw_explosion(enemy.vertices, NUM_ENEMY_VERTICES, |
646 | enemy_x, enemy.position.y/SCALE); | 865 | // enemy_x, enemy.position.y/SCALE); |
647 | if(game_state != PAUSE_MODE) | 866 | if(game_state != PAUSE_MODE) |
648 | { | 867 | { |
649 | enemy.explode_countdown--; | 868 | enemy.explode_countdown--; |
@@ -654,8 +873,8 @@ void draw_and_move_enemy(void) | |||
654 | } | 873 | } |
655 | else | 874 | else |
656 | { | 875 | { |
657 | if( (rb->rand()%1000) < 2 ) | 876 | if( (*rb->current_tick - enemy.last_time_appeared) > enemy.appear_timing) |
658 | initialise_enemy(); | 877 | if(rb->rand()%100 > enemy.appear_probability) initialise_enemy(); |
659 | } | 878 | } |
660 | 879 | ||
661 | if(!enemy_missile.survived && game_state != GAME_OVER) | 880 | if(!enemy_missile.survived && game_state != GAME_OVER) |
@@ -732,7 +951,7 @@ bool is_point_within_asteroid(struct Asteroid* asteroid, struct Point* point) | |||
732 | { | 951 | { |
733 | case(SMALL): | 952 | case(SMALL): |
734 | asteroid->explode_countdown = EXPLOSION_LENGTH; | 953 | asteroid->explode_countdown = EXPLOSION_LENGTH; |
735 | initialise_explosion(asteroid->vertices, NUM_ASTEROID_VERTICES); | 954 | create_trail_blaze(ASTEROID_EXPLOSION_COLOUR, &asteroid->position); |
736 | break; | 955 | break; |
737 | 956 | ||
738 | case(LARGE): | 957 | case(LARGE): |
@@ -749,6 +968,11 @@ bool is_point_within_asteroid(struct Asteroid* asteroid, struct Point* point) | |||
749 | } | 968 | } |
750 | 969 | ||
751 | current_score++; | 970 | current_score++; |
971 | if(current_score > extra_life) | ||
972 | { | ||
973 | num_lives++; | ||
974 | extra_life = current_score+EXTRA_LIFE; | ||
975 | } | ||
752 | asteroid_count--; | 976 | asteroid_count--; |
753 | asteroid->exists = false; | 977 | asteroid->exists = false; |
754 | return true; | 978 | return true; |
@@ -759,12 +983,13 @@ bool is_point_within_asteroid(struct Asteroid* asteroid, struct Point* point) | |||
759 | 983 | ||
760 | bool is_point_within_enemy(struct Point* point) | 984 | bool is_point_within_enemy(struct Point* point) |
761 | { | 985 | { |
762 | if( is_point_within_rectangle(&enemy.position, point, 5*SCALE) ) | 986 | if( is_point_within_rectangle(&enemy.position, point, 7*SCALE) ) |
763 | { | 987 | { |
764 | current_score += 5; | 988 | current_score += 5; |
765 | /*enemy_missile.survived = 0;*/ | 989 | /*enemy_missile.survived = 0;*/ |
766 | enemy.explode_countdown = EXPLOSION_LENGTH; | 990 | enemy.explode_countdown = EXPLOSION_LENGTH; |
767 | initialise_explosion(enemy.vertices, NUM_ENEMY_VERTICES); | 991 | // initialise_explosion(enemy.vertices, NUM_ENEMY_VERTICES); |
992 | create_trail_blaze(ENEMY_EXPLOSION_COLOUR, &enemy.position); | ||
768 | return true; | 993 | return true; |
769 | } | 994 | } |
770 | else | 995 | else |
@@ -808,6 +1033,7 @@ void initialise_explosion(struct Point* point, int num_points) | |||
808 | point->dy = point->y; | 1033 | point->dy = point->y; |
809 | point++; | 1034 | point++; |
810 | } | 1035 | } |
1036 | |||
811 | } | 1037 | } |
812 | 1038 | ||
813 | /* Check for collsions between the missiles and the asteroids and the ship */ | 1039 | /* Check for collsions between the missiles and the asteroids and the ship */ |
@@ -844,41 +1070,37 @@ void check_collisions(void) | |||
844 | } | 1070 | } |
845 | missile++; | 1071 | missile++; |
846 | } | 1072 | } |
847 | } | ||
848 | 1073 | ||
849 | /*If it exists now, check ship collision:*/ | ||
850 | if(asteroid->exists) | ||
851 | { | ||
852 | /*now check collision with ship:*/ | 1074 | /*now check collision with ship:*/ |
853 | if(!ship.waiting_for_space && !ship.explode_countdown) | 1075 | if(asteroid->exists && !ship.waiting_for_space && !ship.explode_countdown) |
854 | { | 1076 | { |
855 | if(is_ship_within_asteroid(asteroid)) | 1077 | if(is_ship_within_asteroid(asteroid)) |
856 | { | 1078 | { |
857 | /*blow up ship*/ | 1079 | /*blow up ship*/ |
858 | ship.explode_countdown = EXPLOSION_LENGTH; | 1080 | ship.explode_countdown = EXPLOSION_LENGTH; |
859 | initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); | 1081 | // initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); |
1082 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | ||
860 | } | 1083 | } |
861 | } | 1084 | |
862 | } | 1085 | /*has the enemy missile blown something up?*/ |
863 | 1086 | if(asteroid->exists && enemy_missile.survived) | |
864 | /*has the enemy missile blown something up?*/ | 1087 | { |
865 | if(asteroid->exists && enemy_missile.survived) | 1088 | if(is_point_within_asteroid(asteroid, &enemy_missile.position)) |
866 | { | 1089 | { |
867 | if(is_point_within_asteroid(asteroid, &enemy_missile.position)) | 1090 | /*take that score back then:*/ |
868 | { | 1091 | if(current_score > 0) current_score--; |
869 | /*take that score back then:*/ | 1092 | enemy_missile.survived = 0; |
870 | if(current_score > 0) current_score--; | 1093 | } |
871 | enemy_missile.survived = 0; | 1094 | |
872 | } | 1095 | /*if it still exists, check if ship is waiting for space:*/ |
873 | } | 1096 | if(asteroid->exists && ship.waiting_for_space) |
874 | 1097 | ship_cant_be_placed |= | |
875 | /*if it still exists, check if ship is waiting for space:*/ | 1098 | is_point_within_rectangle(&ship.position, |
876 | if(asteroid->exists && ship.waiting_for_space) | ||
877 | ship_cant_be_placed |= | ||
878 | is_point_within_rectangle(&ship.position, | ||
879 | &asteroid->position, | 1099 | &asteroid->position, |
880 | space_check_size); | 1100 | space_check_size); |
881 | 1101 | } | |
1102 | } | ||
1103 | } | ||
882 | /*is an asteroid still exploding?*/ | 1104 | /*is an asteroid still exploding?*/ |
883 | if(asteroid->explode_countdown) | 1105 | if(asteroid->explode_countdown) |
884 | asteroids_onscreen = true; | 1106 | asteroids_onscreen = true; |
@@ -894,7 +1116,9 @@ void check_collisions(void) | |||
894 | if(is_point_within_enemy(&ship.position)) | 1116 | if(is_point_within_enemy(&ship.position)) |
895 | { | 1117 | { |
896 | ship.explode_countdown = EXPLOSION_LENGTH; | 1118 | ship.explode_countdown = EXPLOSION_LENGTH; |
897 | initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); | 1119 | //initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); |
1120 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | ||
1121 | create_trail_blaze(ENEMY_EXPLOSION_COLOUR, &enemy.position); | ||
898 | } | 1122 | } |
899 | 1123 | ||
900 | /*Now see if the enemy has been shot at by the ships missiles:*/ | 1124 | /*Now see if the enemy has been shot at by the ships missiles:*/ |
@@ -908,6 +1132,7 @@ void check_collisions(void) | |||
908 | missile->survived = 0; | 1132 | missile->survived = 0; |
909 | break; | 1133 | break; |
910 | } | 1134 | } |
1135 | missile++; | ||
911 | } | 1136 | } |
912 | } | 1137 | } |
913 | 1138 | ||
@@ -918,7 +1143,8 @@ void check_collisions(void) | |||
918 | enemy_missile.position.y - ship.position.y)) | 1143 | enemy_missile.position.y - ship.position.y)) |
919 | { | 1144 | { |
920 | ship.explode_countdown = EXPLOSION_LENGTH; | 1145 | ship.explode_countdown = EXPLOSION_LENGTH; |
921 | initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); | 1146 | //initialise_explosion(ship.vertices, NUM_SHIP_VERTICES); |
1147 | create_trail_blaze(SHIP_EXPLOSION_COLOUR, &ship.position); | ||
922 | enemy_missile.survived = 0; | 1148 | enemy_missile.survived = 0; |
923 | enemy_missile.position.x = enemy_missile.position.y = 0; | 1149 | enemy_missile.position.x = enemy_missile.position.y = 0; |
924 | } | 1150 | } |
@@ -931,6 +1157,10 @@ void check_collisions(void) | |||
931 | { | 1157 | { |
932 | current_level++; | 1158 | current_level++; |
933 | game_state = SHOW_LEVEL; | 1159 | game_state = SHOW_LEVEL; |
1160 | enemy.appear_probability += 5; | ||
1161 | enemy.appear_timing -= 200; | ||
1162 | if( enemy.appear_probability > 100) | ||
1163 | enemy.appear_probability = ENEMY_APPEAR_PROBABILITY_START; | ||
934 | show_level_timeout = SHOW_LEVEL_TIME; | 1164 | show_level_timeout = SHOW_LEVEL_TIME; |
935 | } | 1165 | } |
936 | } | 1166 | } |
@@ -962,8 +1192,8 @@ void create_asteroid(enum asteroid_type type, int x, int y) | |||
962 | /* Initialise a missile */ | 1192 | /* Initialise a missile */ |
963 | void initialise_missile(struct Missile* missile) | 1193 | void initialise_missile(struct Missile* missile) |
964 | { | 1194 | { |
965 | missile->position.x = ship.position.x; | 1195 | missile->position.x = ship.position.x + ship.vertices[0].x; |
966 | missile->position.y = ship.position.y; | 1196 | missile->position.y = ship.position.y + ship.vertices[0].y; |
967 | missile->position.dx = (ship.vertices[0].x - ship.vertices[2].x)/2; | 1197 | missile->position.dx = (ship.vertices[0].x - ship.vertices[2].x)/2; |
968 | missile->position.dy = (ship.vertices[0].y - ship.vertices[2].y)/2; | 1198 | missile->position.dy = (ship.vertices[0].y - ship.vertices[2].y)/2; |
969 | missile->survived = MISSILE_SURVIVAL_LENGTH; | 1199 | missile->survived = MISSILE_SURVIVAL_LENGTH; |
@@ -1105,7 +1335,7 @@ void initialise_asteroid(struct Asteroid* asteroid, enum asteroid_type type) | |||
1105 | asteroid->explode_countdown = 0; | 1335 | asteroid->explode_countdown = 0; |
1106 | 1336 | ||
1107 | /*Set the radius of the asteroid:*/ | 1337 | /*Set the radius of the asteroid:*/ |
1108 | asteroid->radius = (int)type; | 1338 | asteroid->radius = (int)type*SCALE; |
1109 | 1339 | ||
1110 | /*shall we move Clockwise and Fast*/ | 1340 | /*shall we move Clockwise and Fast*/ |
1111 | if((rb->rand()%100)>75) | 1341 | if((rb->rand()%100)>75) |
@@ -1136,33 +1366,31 @@ void initialise_asteroid(struct Asteroid* asteroid, enum asteroid_type type) | |||
1136 | { | 1366 | { |
1137 | if(b) | 1367 | if(b) |
1138 | { | 1368 | { |
1139 | point->x = asteroid_one[n]*asteroid->radius/2; | 1369 | point->x = asteroid_one[n]; |
1140 | point->y = asteroid_one[n+1]*asteroid->radius/2; | 1370 | point->y = asteroid_one[n+1]; |
1141 | } | 1371 | } |
1142 | else if( b2 ) | 1372 | else if( b2 ) |
1143 | { | 1373 | { |
1144 | point->x = asteroid_two[n]*asteroid->radius/2; | 1374 | point->x = asteroid_two[n]; |
1145 | point->y = asteroid_two[n+1]*asteroid->radius/2; | 1375 | point->y = asteroid_two[n+1]; |
1146 | } | 1376 | } |
1147 | else | 1377 | else |
1148 | { | 1378 | { |
1149 | point->x = asteroid_three[n]*asteroid->radius/2; | 1379 | point->x = asteroid_three[n]; |
1150 | point->y = asteroid_three[n+1]*asteroid->radius/2; | 1380 | point->y = asteroid_three[n+1]; |
1151 | } | 1381 | } |
1152 | point->x *= SCALE; | 1382 | |
1153 | point->y *= SCALE; | 1383 | point->x *= asteroid->radius/6; |
1384 | point->y *= asteroid->radius/6; | ||
1154 | point++; | 1385 | point++; |
1155 | } | 1386 | } |
1156 | 1387 | ||
1157 | asteroid->radius *= SCALE/2; | ||
1158 | |||
1159 | if(asteroid->type == LARGE) | ||
1160 | asteroid->radius *= 7; | ||
1161 | else if(asteroid->type == MEDIUM) | ||
1162 | asteroid->radius *= 4; | ||
1163 | else if(asteroid->type == SMALL) | ||
1164 | asteroid->radius /= 2; | ||
1165 | 1388 | ||
1389 | asteroid->radius += 6*SCALE; | ||
1390 | if(asteroid->type == SMALL) | ||
1391 | asteroid->radius /= 3;//2 | ||
1392 | else if(asteroid->type == LARGE) | ||
1393 | asteroid->radius += 3*SCALE;//2 | ||
1166 | b = true; | 1394 | b = true; |
1167 | while(b) | 1395 | while(b) |
1168 | { | 1396 | { |
@@ -1172,11 +1400,11 @@ void initialise_asteroid(struct Asteroid* asteroid, enum asteroid_type type) | |||
1172 | 1400 | ||
1173 | asteroid->position.dx = 0; | 1401 | asteroid->position.dx = 0; |
1174 | while(asteroid->position.dx == 0) | 1402 | while(asteroid->position.dx == 0) |
1175 | asteroid->position.dx = (rb->rand()%10)-5; | 1403 | asteroid->position.dx = (rb->rand()%ASTEROID_SPEED)-ASTEROID_SPEED/2; |
1176 | 1404 | ||
1177 | asteroid->position.dy = 0; | 1405 | asteroid->position.dy = 0; |
1178 | while(asteroid->position.dy == 0) | 1406 | while(asteroid->position.dy == 0) |
1179 | asteroid->position.dy = (rb->rand()%10)-5; | 1407 | asteroid->position.dy = (rb->rand()%ASTEROID_SPEED)-ASTEROID_SPEED/2; |
1180 | 1408 | ||
1181 | asteroid->position.dx *= SCALE/10; | 1409 | asteroid->position.dx *= SCALE/10; |
1182 | asteroid->position.dy *= SCALE/10; | 1410 | asteroid->position.dy *= SCALE/10; |
@@ -1223,7 +1451,7 @@ void initialise_ship(void) | |||
1223 | ship.explode_countdown = 0; | 1451 | ship.explode_countdown = 0; |
1224 | 1452 | ||
1225 | /*hack-o-rama-city-arizona, take it out to see what happens:*/ | 1453 | /*hack-o-rama-city-arizona, take it out to see what happens:*/ |
1226 | for(n=17;--n;) | 1454 | for(n=30;--n;) |
1227 | rotate_ship(SHIP_ROT_ACW_COS, SHIP_ROT_ACW_SIN); | 1455 | rotate_ship(SHIP_ROT_ACW_COS, SHIP_ROT_ACW_SIN); |
1228 | 1456 | ||
1229 | /*grab a copy of the ships points for the lives display:*/ | 1457 | /*grab a copy of the ships points for the lives display:*/ |
@@ -1268,13 +1496,19 @@ void draw_and_move_ship(void) | |||
1268 | if(!ship.explode_countdown) | 1496 | if(!ship.explode_countdown) |
1269 | { | 1497 | { |
1270 | if(!ship.waiting_for_space) | 1498 | if(!ship.waiting_for_space) |
1271 | draw_polygon(ship.vertices, nxoffset, nyoffset, NUM_SHIP_VERTICES); | 1499 | { |
1500 | draw_polygon(ship.vertices, nxoffset, nyoffset, NUM_SHIP_VERTICES); | ||
1501 | if(game_state != PAUSE_MODE && game_state != GAME_OVER) | ||
1502 | { | ||
1503 | move_point(&ship.position); | ||
1504 | } | ||
1505 | } | ||
1272 | } | 1506 | } |
1273 | else | 1507 | else |
1274 | { | 1508 | { |
1275 | animate_and_draw_explosion(ship.vertices, NUM_SHIP_VERTICES, | 1509 | // animate_and_draw_explosion(ship.vertices, NUM_SHIP_VERTICES, |
1276 | ship.position.x/SCALE, | 1510 | // ship.position.x/SCALE, |
1277 | ship.position.y/SCALE); | 1511 | // ship.position.y/SCALE); |
1278 | if(game_state != PAUSE_MODE) | 1512 | if(game_state != PAUSE_MODE) |
1279 | { | 1513 | { |
1280 | ship.explode_countdown--; | 1514 | ship.explode_countdown--; |
@@ -1294,18 +1528,18 @@ void draw_and_move_ship(void) | |||
1294 | } | 1528 | } |
1295 | } | 1529 | } |
1296 | } | 1530 | } |
1297 | |||
1298 | if(game_state != PAUSE_MODE && game_state != GAME_OVER) | ||
1299 | move_point(&ship.position); | ||
1300 | } | 1531 | } |
1301 | 1532 | ||
1302 | void thrust_ship(void) | 1533 | void thrust_ship(void) |
1303 | { | 1534 | { |
1304 | if(!ship.waiting_for_space) | 1535 | if(!ship.waiting_for_space) |
1305 | { | 1536 | { |
1306 | ship.position.dx += ( ship.vertices[0].x - ship.vertices[2].x )/10; | 1537 | ship.position.dx += ( ship.vertices[0].x - ship.vertices[2].x )/20; |
1307 | ship.position.dy += ( ship.vertices[0].y - ship.vertices[2].y )/10; | 1538 | ship.position.dy += ( ship.vertices[0].y - ship.vertices[2].y )/20; |
1308 | /*if dx and dy are below a certain threshold, then set 'em to 0*/ | 1539 | /*if dx and dy are below a certain threshold, then set 'em to 0*/ |
1540 | //but to do this we need to ascertain if the spacehip as moved on screen for more than a certain amount. | ||
1541 | |||
1542 | create_trail_blaze(THRUST_COLOUR, &ship.position); | ||
1309 | } | 1543 | } |
1310 | } | 1544 | } |
1311 | 1545 | ||
@@ -1372,12 +1606,11 @@ void draw_and_move_asteroids(void) | |||
1372 | } | 1606 | } |
1373 | else if(asteroid->explode_countdown) | 1607 | else if(asteroid->explode_countdown) |
1374 | { | 1608 | { |
1375 | animate_and_draw_explosion(asteroid->vertices, | 1609 | // animate_and_draw_explosion(asteroid->vertices, |
1376 | NUM_ASTEROID_VERTICES, | 1610 | // NUM_ASTEROID_VERTICES, |
1377 | asteroid->position.x/SCALE, | 1611 | // asteroid->position.x/SCALE, |
1378 | asteroid->position.y/SCALE); | 1612 | // asteroid->position.y/SCALE); |
1379 | if(game_state != PAUSE_MODE) | 1613 | asteroid->explode_countdown--; |
1380 | asteroid->explode_countdown--; | ||
1381 | } | 1614 | } |
1382 | } | 1615 | } |
1383 | else | 1616 | else |
@@ -1394,8 +1627,9 @@ void draw_and_move_asteroids(void) | |||
1394 | 1627 | ||
1395 | void create_stars(void) | 1628 | void create_stars(void) |
1396 | { | 1629 | { |
1397 | struct Point* p; | 1630 | struct TrailPoint* tpoint; |
1398 | int n; | 1631 | struct Point* p; |
1632 | int n; | ||
1399 | 1633 | ||
1400 | p = stars; | 1634 | p = stars; |
1401 | n = NUM_STARS; | 1635 | n = NUM_STARS; |
@@ -1405,6 +1639,16 @@ void create_stars(void) | |||
1405 | p->y = (rb->rand()%LCD_HEIGHT); | 1639 | p->y = (rb->rand()%LCD_HEIGHT); |
1406 | p++; | 1640 | p++; |
1407 | } | 1641 | } |
1642 | |||
1643 | |||
1644 | //give the point a random countdown timer, so they dissapears at different times | ||
1645 | tpoint = trailPoints; | ||
1646 | n = NUM_TRAIL_POINTS; | ||
1647 | while(--n) | ||
1648 | { | ||
1649 | tpoint->alive = 0; | ||
1650 | tpoint++; | ||
1651 | } | ||
1408 | } | 1652 | } |
1409 | 1653 | ||
1410 | /************************************************* | 1654 | /************************************************* |
@@ -1417,7 +1661,8 @@ void initialise_game(int start_num) | |||
1417 | asteroid_count = next_missile_count = next_thrust_count = 0; | 1661 | asteroid_count = next_missile_count = next_thrust_count = 0; |
1418 | struct Asteroid* asteroid; | 1662 | struct Asteroid* asteroid; |
1419 | struct Missile* missile; | 1663 | struct Missile* missile; |
1420 | 1664 | extra_life = EXTRA_LIFE; | |
1665 | |||
1421 | /*no enemy*/ | 1666 | /*no enemy*/ |
1422 | enemy_on_screen = 0; | 1667 | enemy_on_screen = 0; |
1423 | enemy_missile.survived = 0; | 1668 | enemy_missile.survived = 0; |
@@ -1447,6 +1692,8 @@ void initialise_game(int start_num) | |||
1447 | 1692 | ||
1448 | void start_attract_mode(void) | 1693 | void start_attract_mode(void) |
1449 | { | 1694 | { |
1695 | enemy.appear_probability = ENEMY_APPEAR_PROBABILITY_START; | ||
1696 | enemy.appear_timing = ENEMY_APPEAR_TIMING_START; | ||
1450 | current_level = 5; | 1697 | current_level = 5; |
1451 | num_lives = START_LIVES; | 1698 | num_lives = START_LIVES; |
1452 | current_score = 0; | 1699 | current_score = 0; |
@@ -1506,7 +1753,7 @@ enum plugin_status start_game(void) | |||
1506 | CENTER_LCD_Y + CENTER_LCD_Y/2 - 4, "Game Over"); | 1753 | CENTER_LCD_Y + CENTER_LCD_Y/2 - 4, "Game Over"); |
1507 | rb->snprintf(s, sizeof(s), "score %d ", current_score); | 1754 | rb->snprintf(s, sizeof(s), "score %d ", current_score); |
1508 | rb->lcd_putsxy(1,LCD_HEIGHT-8, s); | 1755 | rb->lcd_putsxy(1,LCD_HEIGHT-8, s); |
1509 | show_game_over--; | 1756 | show_game_over--; |
1510 | if(!show_game_over) | 1757 | if(!show_game_over) |
1511 | start_attract_mode(); | 1758 | start_attract_mode(); |
1512 | break; | 1759 | break; |
@@ -1547,6 +1794,7 @@ enum plugin_status start_game(void) | |||
1547 | } | 1794 | } |
1548 | break; | 1795 | break; |
1549 | } | 1796 | } |
1797 | draw_trail_blaze(); | ||
1550 | drawstars(); | 1798 | drawstars(); |
1551 | draw_and_move_asteroids(); | 1799 | draw_and_move_asteroids(); |
1552 | draw_and_move_enemy(); | 1800 | draw_and_move_enemy(); |