Nemesis game, stats
Diff: Stats.cpp
- Revision:
- 9:b9ad5e45aebf
- Parent:
- 8:b8e8e2f335e1
- Child:
- 10:c5ef17e93872
--- a/Stats.cpp Sun Apr 09 12:47:00 2017 +0000 +++ b/Stats.cpp Mon May 01 13:02:42 2017 +0000 @@ -10,6 +10,22 @@ } +void Stats::grid_draw(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 + lcd.drawLine(WIDTH-11, HEIGHT-8, WIDTH-11, HEIGHT, 1); // health border, left side + lcd.drawLine(18, HEIGHT-1, WIDTH, HEIGHT-1, 1); // bottom border + lcd.drawLine(18, HEIGHT-8, 18, HEIGHT, 1); // wave counter border, right side +} + +void Stats::wave_draw(N5110 &lcd, int wave_counter) +{ + char buffer[14]; + int length = sprintf(buffer,"%2d",wave_counter); + lcd.printString(buffer,0,5); +} + void Stats::draw_health(N5110 &lcd) { lcd.drawLine(76,40,77,40,1); @@ -24,6 +40,61 @@ lcd.setPixel(78,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); +} + +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); +} + +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); +} + +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_health(N5110 &lcd, int collisions) { if (collisions == 0) @@ -59,4 +130,5 @@ else if (collisions >= 5) { } -} \ No newline at end of file +} +