summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2009-09-05 13:02:21 +0000
committerTeruaki Kawashima <teru@rockbox.org>2009-09-05 13:02:21 +0000
commitf85e53f1149220f25c8be077b517ab3e3d5f7cd9 (patch)
treee3d2d7e000b3b32513fe1f1c6148628d9d643893 /apps
parent24170236527c148b60aeb1acbf32b0a3215318dc (diff)
downloadrockbox-f85e53f1149220f25c8be077b517ab3e3d5f7cd9.tar.gz
rockbox-f85e53f1149220f25c8be077b517ab3e3d5f7cd9.zip
remove extra 1 element in arrays. use same counter for both manual and auto fire. break long lines.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22630 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/fireworks.c110
1 files changed, 63 insertions, 47 deletions
diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c
index 4b3e2fd117..c7c7b58b93 100644
--- a/apps/plugins/fireworks.c
+++ b/apps/plugins/fireworks.c
@@ -137,22 +137,22 @@ PLUGIN_HEADER
137#define FIREWORK_SIZE 2 137#define FIREWORK_SIZE 2
138 138
139/* position, speed, "phase" (age), color of all fireworks */ 139/* position, speed, "phase" (age), color of all fireworks */
140int firework_xpoints[MAX_ROCKETS+1][MAX_FIREWORKS]; 140int firework_xpoints[MAX_ROCKETS][MAX_FIREWORKS];
141int firework_ypoints[MAX_ROCKETS+1][MAX_FIREWORKS]; 141int firework_ypoints[MAX_ROCKETS][MAX_FIREWORKS];
142int firework_xspeed[MAX_ROCKETS+1][MAX_FIREWORKS]; 142int firework_xspeed[MAX_ROCKETS][MAX_FIREWORKS];
143int firework_yspeed[MAX_ROCKETS+1][MAX_FIREWORKS]; 143int firework_yspeed[MAX_ROCKETS][MAX_FIREWORKS];
144int firework_phase[MAX_ROCKETS+1]; 144int firework_phase[MAX_ROCKETS];
145#ifdef HAVE_LCD_COLOR 145#ifdef HAVE_LCD_COLOR
146int firework_color[MAX_ROCKETS+1][MAX_FIREWORKS]; 146int firework_color[MAX_ROCKETS][MAX_FIREWORKS];
147#endif 147#endif
148 148
149/* position, speed, "phase" (age) of all rockets */ 149/* position, speed, "phase" (age) of all rockets */
150int rocket_xpos[MAX_ROCKETS+1]; 150int rocket_xpos[MAX_ROCKETS];
151int rocket_ypos[MAX_ROCKETS+1]; 151int rocket_ypos[MAX_ROCKETS];
152int rocket_xspeed[MAX_ROCKETS+1]; 152int rocket_xspeed[MAX_ROCKETS];
153int rocket_yspeed[MAX_ROCKETS+1]; 153int rocket_yspeed[MAX_ROCKETS];
154int rocket_phase[MAX_ROCKETS+1]; 154int rocket_phase[MAX_ROCKETS];
155int rocket_targetphase[MAX_ROCKETS+1]; 155int rocket_targetphase[MAX_ROCKETS];
156 156
157/* settings values. these should eventually be saved to 157/* settings values. these should eventually be saved to
158 * disk. maybe a preset loading/saving system? */ 158 * disk. maybe a preset loading/saving system? */
@@ -301,7 +301,10 @@ void init_all(void)
301 int j; 301 int j;
302 302
303 for(j=0; j<MAX_ROCKETS; j++) 303 for(j=0; j<MAX_ROCKETS; j++)
304 {
305 rocket_phase[j] = -1;
304 firework_phase[j] = -1; 306 firework_phase[j] = -1;
307 }
305} 308}
306 309
307/* called when a rocket hits its destination height. 310/* called when a rocket hits its destination height.
@@ -317,8 +320,10 @@ void init_explode(int x, int y, int firework, int points)
317 firework_xpoints[firework][i] = x; 320 firework_xpoints[firework][i] = x;
318 firework_ypoints[firework][i] = y; 321 firework_ypoints[firework][i] = y;
319 322
320 firework_xspeed[firework][i] = (rb->rand() % FIREWORK_MOVEMENT_RANGE) - FIREWORK_MOVEMENT_RANGE/2; 323 firework_xspeed[firework][i] = (rb->rand() % FIREWORK_MOVEMENT_RANGE)
321 firework_yspeed[firework][i] = (rb->rand() % FIREWORK_MOVEMENT_RANGE) - FIREWORK_MOVEMENT_RANGE/2; 324 - FIREWORK_MOVEMENT_RANGE/2;
325 firework_yspeed[firework][i] = (rb->rand() % FIREWORK_MOVEMENT_RANGE)
326 - FIREWORK_MOVEMENT_RANGE/2;
322 327
323#ifdef HAVE_LCD_COLOR 328#ifdef HAVE_LCD_COLOR
324 firework_color[firework][i] = rb->rand() % 7; 329 firework_color[firework][i] = rb->rand() % 7;
@@ -335,10 +340,13 @@ void init_rocket(int rocket)
335 rocket_xpos[rocket] = rb->rand() % LCD_WIDTH; 340 rocket_xpos[rocket] = rb->rand() % LCD_WIDTH;
336 rocket_ypos[rocket] = LCD_HEIGHT; 341 rocket_ypos[rocket] = LCD_HEIGHT;
337 342
338 rocket_xspeed[rocket] = (rb->rand() % ROCKET_MOVEMENT_RANGE) - ROCKET_MOVEMENT_RANGE/2; 343 rocket_xspeed[rocket] = (rb->rand() % ROCKET_MOVEMENT_RANGE)
344 - ROCKET_MOVEMENT_RANGE/2;
339 rocket_yspeed[rocket] = 3; 345 rocket_yspeed[rocket] = 3;
340 346
341 rocket_targetphase[rocket] = (ROCKET_LIFE + (rb->rand() % ROCKET_LIFE_VAR)) / rocket_yspeed[rocket]; 347 rocket_phase[rocket] = 0;
348 rocket_targetphase[rocket] = (ROCKET_LIFE + (rb->rand() % ROCKET_LIFE_VAR))
349 / rocket_yspeed[rocket];
342} 350}
343 351
344/* startup/configuration menu. */ 352/* startup/configuration menu. */
@@ -379,27 +387,33 @@ void fireworks_menu(void)
379 break; 387 break;
380 388
381 case 1: 389 case 1:
382 rb->set_option("Auto-Fire", &autofire_delay, INT, autofire_delay_settings, 15, NULL); 390 rb->set_option("Auto-Fire", &autofire_delay, INT,
391 autofire_delay_settings, 15, NULL);
383 break; 392 break;
384 393
385 case 2: 394 case 2:
386 rb->set_option("Particles Per Firework", &particles_per_firework, INT, particle_settings, 8, NULL); 395 rb->set_option("Particles Per Firework", &particles_per_firework,
396 INT, particle_settings, 8, NULL);
387 break; 397 break;
388 398
389 case 3: 399 case 3:
390 rb->set_option("Particle Life", &particle_life, INT, particle_life_settings, 9, NULL); 400 rb->set_option("Particle Life", &particle_life, INT,
401 particle_life_settings, 9, NULL);
391 break; 402 break;
392 403
393 case 4: 404 case 4:
394 rb->set_option("Gravity", &gravity, INT, gravity_settings, 4, NULL); 405 rb->set_option("Gravity", &gravity, INT,
406 gravity_settings, 4, NULL);
395 break; 407 break;
396 408
397 case 5: 409 case 5:
398 rb->set_option("Show Rockets", &show_rockets, INT, rocket_settings, 3, NULL); 410 rb->set_option("Show Rockets", &show_rockets, INT,
411 rocket_settings, 3, NULL);
399 break; 412 break;
400 413
401 case 6: 414 case 6:
402 rb->set_option("FPS (Speed)", &frames_per_second, INT, fps_settings, 9, NULL); 415 rb->set_option("FPS (Speed)", &frames_per_second, INT,
416 fps_settings, 9, NULL);
403 break; 417 break;
404 418
405 case 7: 419 case 7:
@@ -419,7 +433,7 @@ enum plugin_status plugin_start(const void* parameter)
419{ 433{
420 (void)parameter; 434 (void)parameter;
421 435
422 int j, i, autofire=0; 436 int j, i;
423 int thisrocket=0; 437 int thisrocket=0;
424 int start_tick, elapsed_tick; 438 int start_tick, elapsed_tick;
425 int button; 439 int button;
@@ -459,7 +473,8 @@ enum plugin_status plugin_start(const void* parameter)
459 rb->lcd_fillrect(rocket_xpos[j], rocket_ypos[j], 473 rb->lcd_fillrect(rocket_xpos[j], rocket_ypos[j],
460 ROCKET_SIZE, ROCKET_SIZE); 474 ROCKET_SIZE, ROCKET_SIZE);
461 rb->lcd_set_foreground(LCD_RGBPACK(64,64,64)); 475 rb->lcd_set_foreground(LCD_RGBPACK(64,64,64));
462 rb->lcd_fillrect(rocket_xpos[j]-rocket_xspeed[j], rocket_ypos[j]+rocket_yspeed[j], 476 rb->lcd_fillrect(rocket_xpos[j]-rocket_xspeed[j],
477 rocket_ypos[j]+rocket_yspeed[j],
463 ROCKET_SIZE, ROCKET_SIZE); 478 ROCKET_SIZE, ROCKET_SIZE);
464 } 479 }
465#endif 480#endif
@@ -484,7 +499,8 @@ enum plugin_status plugin_start(const void* parameter)
484 rocket_phase[j] = -1; 499 rocket_phase[j] = -1;
485 500
486 firework_phase[j] = 0; 501 firework_phase[j] = 0;
487 init_explode(rocket_xpos[j], rocket_ypos[j], j, particle_values[particles_per_firework]); 502 init_explode(rocket_xpos[j], rocket_ypos[j], j,
503 particle_values[particles_per_firework]);
488 } 504 }
489 } 505 }
490 506
@@ -497,22 +513,30 @@ enum plugin_status plugin_start(const void* parameter)
497 firework_ypoints[j][i] += firework_yspeed[j][i]; 513 firework_ypoints[j][i] += firework_yspeed[j][i];
498 514
499 if(gravity != 0) 515 if(gravity != 0)
500 firework_ypoints[j][i] += firework_phase[j]/gravity_values[gravity]; 516 firework_ypoints[j][i] += firework_phase[j]
517 /gravity_values[gravity];
501 518
502#ifdef HAVE_LCD_COLOR 519#ifdef HAVE_LCD_COLOR
503 rb->lcd_set_foreground(firework_darkest_colors[firework_color[j][i]]); 520 rb->lcd_set_foreground(
521 firework_darkest_colors[firework_color[j][i]]);
504 rb->lcd_fillrect(firework_xpoints[j][i]-1, 522 rb->lcd_fillrect(firework_xpoints[j][i]-1,
505 firework_ypoints[j][i]-1, 523 firework_ypoints[j][i]-1,
506 FIREWORK_SIZE+2, FIREWORK_SIZE+2); 524 FIREWORK_SIZE+2, FIREWORK_SIZE+2);
507 525
508 if(firework_phase[j] < particle_life_values[particle_life]-10) 526 int phase_left = particle_life_values[particle_life]
509 rb->lcd_set_foreground(firework_colors[firework_color[j][i]]); 527 - firework_phase[j];
510 else if(firework_phase[j] < particle_life_values[particle_life]-7) 528 if(phase_left > 10)
511 rb->lcd_set_foreground(firework_dark_colors[firework_color[j][i]]); 529 rb->lcd_set_foreground(
512 else if(firework_phase[j] < particle_life_values[particle_life]-3) 530 firework_colors[firework_color[j][i]]);
513 rb->lcd_set_foreground(firework_darker_colors[firework_color[j][i]]); 531 else if(phase_left > 7)
532 rb->lcd_set_foreground(
533 firework_dark_colors[firework_color[j][i]]);
534 else if(phase_left > 3)
535 rb->lcd_set_foreground(
536 firework_darker_colors[firework_color[j][i]]);
514 else 537 else
515 rb->lcd_set_foreground(firework_darkest_colors[firework_color[j][i]]); 538 rb->lcd_set_foreground(
539 firework_darkest_colors[firework_color[j][i]]);
516#endif 540#endif
517 rb->lcd_fillrect(firework_xpoints[j][i], 541 rb->lcd_fillrect(firework_xpoints[j][i],
518 firework_ypoints[j][i], 542 firework_ypoints[j][i],
@@ -549,15 +573,11 @@ enum plugin_status plugin_start(const void* parameter)
549 573
550 if(elapsed_tick > autofire_delay_values[autofire_delay]) 574 if(elapsed_tick > autofire_delay_values[autofire_delay])
551 { 575 {
552 rocket_phase[autofire] = 0; 576 init_rocket(thisrocket);
553 init_rocket(autofire); 577 if(++thisrocket == MAX_ROCKETS)
578 thisrocket = 0;
554 579
555 start_tick = *rb->current_tick; 580 start_tick = *rb->current_tick;
556
557 if(autofire < MAX_ROCKETS)
558 autofire++;
559 else
560 autofire = 0;
561 } 581 }
562 } 582 }
563 583
@@ -572,13 +592,9 @@ enum plugin_status plugin_start(const void* parameter)
572 592
573 case BTN_FIRE: /* fire off rockets manually */ 593 case BTN_FIRE: /* fire off rockets manually */
574 case BTN_FIRE|BUTTON_REPEAT: 594 case BTN_FIRE|BUTTON_REPEAT:
575 if(thisrocket < MAX_ROCKETS)
576 thisrocket++;
577 else
578 thisrocket=0;
579
580 rocket_phase[thisrocket] = 0;
581 init_rocket(thisrocket); 595 init_rocket(thisrocket);
596 if(++thisrocket == MAX_ROCKETS)
597 thisrocket=0;
582 break; 598 break;
583 } 599 }
584 } 600 }