Nemesis game, stats
Diff: Stats.cpp
- Revision:
- 10:c5ef17e93872
- Parent:
- 9:b9ad5e45aebf
- Child:
- 11:deba1e6f8d78
--- a/Stats.cpp Mon May 01 13:02:42 2017 +0000 +++ b/Stats.cpp Tue May 02 22:13:28 2017 +0000 @@ -10,7 +10,7 @@ } -void Stats::grid_draw(N5110 &lcd) +void Stats::draw_grid(N5110 &lcd) { lcd.drawRect(0, 0, WIDTH, HEIGHT-8, FILL_TRANSPARENT); // outer border lcd.drawLine(WIDTH-1, HEIGHT-8, WIDTH-1, HEIGHT, 1); // health border, right side @@ -19,7 +19,7 @@ lcd.drawLine(18, HEIGHT-8, 18, HEIGHT, 1); // wave counter border, right side } -void Stats::wave_draw(N5110 &lcd, int wave_counter) +void Stats::draw_wave_counter(N5110 &lcd, int wave_counter) { char buffer[14]; int length = sprintf(buffer,"%2d",wave_counter); @@ -42,59 +42,46 @@ void Stats::draw_rocket1(N5110 &lcd, int state) { - lcd.drawLine(22, HEIGHT-3, 25, HEIGHT-3, state); - lcd.drawLine(23, HEIGHT-4, 35, HEIGHT-4, state); - lcd.drawLine(24, HEIGHT-5, 36, HEIGHT-5, state); - lcd.drawLine(23, HEIGHT-6, 35, HEIGHT-6, state); - lcd.drawLine(22, HEIGHT-7, 25, HEIGHT-7, state); + lcd.drawLine(27, HEIGHT-3, 30, HEIGHT-3, state); + lcd.drawLine(28, HEIGHT-4, 40, HEIGHT-4, state); + lcd.drawLine(29, HEIGHT-5, 41, HEIGHT-5, state); + lcd.drawLine(28, HEIGHT-6, 40, HEIGHT-6, state); + lcd.drawLine(27, HEIGHT-7, 30, HEIGHT-7, state); } void Stats::draw_rocket2(N5110 &lcd, int state) { - lcd.drawLine(39, HEIGHT-3, 42, HEIGHT-3, state); - lcd.drawLine(40, HEIGHT-4, 52, HEIGHT-4, state); - lcd.drawLine(41, HEIGHT-5, 53, HEIGHT-5, state); - lcd.drawLine(40, HEIGHT-6, 52, HEIGHT-6, state); - lcd.drawLine(39, HEIGHT-7, 42, HEIGHT-7, state); + lcd.drawLine(42, HEIGHT-3, 45, HEIGHT-3, state); + lcd.drawLine(43, HEIGHT-4, 55, HEIGHT-4, state); + lcd.drawLine(44, HEIGHT-5, 56, HEIGHT-5, state); + lcd.drawLine(43, HEIGHT-6, 55, HEIGHT-6, state); + lcd.drawLine(42, HEIGHT-7, 45, HEIGHT-7, state); } void Stats::draw_rocket3(N5110 &lcd, int state) { - lcd.drawLine(56, HEIGHT-3, 59, HEIGHT-3, state); - lcd.drawLine(57, HEIGHT-4, 69, HEIGHT-4, state); - lcd.drawLine(58, HEIGHT-5, 70, HEIGHT-5, state); - lcd.drawLine(57, HEIGHT-6, 69, HEIGHT-6, state); - lcd.drawLine(56, HEIGHT-7, 59, HEIGHT-7, state); + lcd.drawLine(57, HEIGHT-3, 60, HEIGHT-3, state); + lcd.drawLine(58, HEIGHT-4, 70, HEIGHT-4, state); + lcd.drawLine(59, HEIGHT-5, 71, HEIGHT-5, state); + lcd.drawLine(58, HEIGHT-6, 70, HEIGHT-6, state); + lcd.drawLine(57, HEIGHT-7, 60, HEIGHT-7, state); } -void Stats::check_rocket(N5110 &lcd, int ammo) + +void Stats::draw_star(N5110 &lcd, int state) { - if (ammo == 3) - { - draw_rocket1(lcd, 1); - draw_rocket2(lcd, 1); - draw_rocket3(lcd, 1); - } - else if (ammo == 2) - { - draw_rocket1(lcd, 1); - draw_rocket2(lcd, 1); - draw_rocket3(lcd, 2); - } - else if (ammo == 1) - { - draw_rocket1(lcd, 1); - draw_rocket2(lcd, 2); - draw_rocket3(lcd, 2); - } - else if (ammo == 0) - { - draw_rocket1(lcd, 2); - draw_rocket2(lcd, 2); - draw_rocket3(lcd, 2); - } + lcd.drawLine(20, HEIGHT-6, 24, HEIGHT-6, state); + lcd.drawLine(20, HEIGHT-4, 24, HEIGHT-4, state); + lcd.drawLine(21, HEIGHT-3, 21, HEIGHT-7, state); + lcd.drawLine(23, HEIGHT-3, 23, HEIGHT-7, state); + lcd.setPixel(20,41); + lcd.setPixel(20,45); + lcd.setPixel(24,41); + lcd.setPixel(24,45); } + + void Stats::check_health(N5110 &lcd, int collisions) { if (collisions == 0) @@ -132,3 +119,36 @@ } } +void Stats::check_rocket(N5110 &lcd, int ammo) +{ + if (ammo == 3) { + draw_rocket1(lcd, 1); + draw_rocket2(lcd, 1); + draw_rocket3(lcd, 1); + } else if (ammo == 2) { + draw_rocket1(lcd, 1); + draw_rocket2(lcd, 1); + draw_rocket3(lcd, 2); + } else if (ammo == 1) { + draw_rocket1(lcd, 1); + draw_rocket2(lcd, 2); + draw_rocket3(lcd, 2); + } else if (ammo == 0) { + draw_rocket1(lcd, 2); + draw_rocket2(lcd, 2); + draw_rocket3(lcd, 2); + } +} + +void Stats::check_star(N5110 &lcd, bool star) +{ + if (star == true) + { + draw_star(lcd, 1); + } + else + { + draw_star(lcd, 2); + } +} +