Nemesis game, stats

Committer:
musallambseiso
Date:
Mon May 01 13:02:42 2017 +0000
Revision:
9:b9ad5e45aebf
Parent:
8:b8e8e2f335e1
Child:
10:c5ef17e93872
Fixed and improved bullet system (generation)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
musallambseiso 7:cae9a95427f7 1 #include "Stats.h"
musallambseiso 5:b822aaa6200d 2
musallambseiso 7:cae9a95427f7 3 Stats::Stats()
musallambseiso 5:b822aaa6200d 4 {
musallambseiso 5:b822aaa6200d 5
musallambseiso 5:b822aaa6200d 6 }
musallambseiso 5:b822aaa6200d 7
musallambseiso 7:cae9a95427f7 8 Stats::~Stats()
musallambseiso 5:b822aaa6200d 9 {
musallambseiso 5:b822aaa6200d 10
musallambseiso 5:b822aaa6200d 11 }
musallambseiso 5:b822aaa6200d 12
musallambseiso 9:b9ad5e45aebf 13 void Stats::grid_draw(N5110 &lcd)
musallambseiso 9:b9ad5e45aebf 14 {
musallambseiso 9:b9ad5e45aebf 15 lcd.drawRect(0, 0, WIDTH, HEIGHT-8, FILL_TRANSPARENT); // outer border
musallambseiso 9:b9ad5e45aebf 16 lcd.drawLine(WIDTH-1, HEIGHT-8, WIDTH-1, HEIGHT, 1); // health border, right side
musallambseiso 9:b9ad5e45aebf 17 lcd.drawLine(WIDTH-11, HEIGHT-8, WIDTH-11, HEIGHT, 1); // health border, left side
musallambseiso 9:b9ad5e45aebf 18 lcd.drawLine(18, HEIGHT-1, WIDTH, HEIGHT-1, 1); // bottom border
musallambseiso 9:b9ad5e45aebf 19 lcd.drawLine(18, HEIGHT-8, 18, HEIGHT, 1); // wave counter border, right side
musallambseiso 9:b9ad5e45aebf 20 }
musallambseiso 9:b9ad5e45aebf 21
musallambseiso 9:b9ad5e45aebf 22 void Stats::wave_draw(N5110 &lcd, int wave_counter)
musallambseiso 9:b9ad5e45aebf 23 {
musallambseiso 9:b9ad5e45aebf 24 char buffer[14];
musallambseiso 9:b9ad5e45aebf 25 int length = sprintf(buffer,"%2d",wave_counter);
musallambseiso 9:b9ad5e45aebf 26 lcd.printString(buffer,0,5);
musallambseiso 9:b9ad5e45aebf 27 }
musallambseiso 9:b9ad5e45aebf 28
musallambseiso 7:cae9a95427f7 29 void Stats::draw_health(N5110 &lcd)
musallambseiso 7:cae9a95427f7 30 {
musallambseiso 7:cae9a95427f7 31 lcd.drawLine(76,40,77,40,1);
musallambseiso 7:cae9a95427f7 32 lcd.drawLine(79,40,80,40,1);
musallambseiso 7:cae9a95427f7 33 lcd.drawLine(75,41,75,43,1);
musallambseiso 7:cae9a95427f7 34 lcd.drawLine(81,41,81,43,1);
musallambseiso 7:cae9a95427f7 35 lcd.setPixel(78,41);
musallambseiso 7:cae9a95427f7 36 lcd.setPixel(76,44);
musallambseiso 7:cae9a95427f7 37 lcd.setPixel(80,44);
musallambseiso 7:cae9a95427f7 38 lcd.setPixel(77,45);
musallambseiso 7:cae9a95427f7 39 lcd.setPixel(79,45);
musallambseiso 7:cae9a95427f7 40 lcd.setPixel(78,46);
musallambseiso 5:b822aaa6200d 41 }
musallambseiso 8:b8e8e2f335e1 42
musallambseiso 9:b9ad5e45aebf 43 void Stats::draw_rocket1(N5110 &lcd, int state)
musallambseiso 9:b9ad5e45aebf 44 {
musallambseiso 9:b9ad5e45aebf 45 lcd.drawLine(22, HEIGHT-3, 25, HEIGHT-3, state);
musallambseiso 9:b9ad5e45aebf 46 lcd.drawLine(23, HEIGHT-4, 35, HEIGHT-4, state);
musallambseiso 9:b9ad5e45aebf 47 lcd.drawLine(24, HEIGHT-5, 36, HEIGHT-5, state);
musallambseiso 9:b9ad5e45aebf 48 lcd.drawLine(23, HEIGHT-6, 35, HEIGHT-6, state);
musallambseiso 9:b9ad5e45aebf 49 lcd.drawLine(22, HEIGHT-7, 25, HEIGHT-7, state);
musallambseiso 9:b9ad5e45aebf 50 }
musallambseiso 9:b9ad5e45aebf 51
musallambseiso 9:b9ad5e45aebf 52 void Stats::draw_rocket2(N5110 &lcd, int state)
musallambseiso 9:b9ad5e45aebf 53 {
musallambseiso 9:b9ad5e45aebf 54 lcd.drawLine(39, HEIGHT-3, 42, HEIGHT-3, state);
musallambseiso 9:b9ad5e45aebf 55 lcd.drawLine(40, HEIGHT-4, 52, HEIGHT-4, state);
musallambseiso 9:b9ad5e45aebf 56 lcd.drawLine(41, HEIGHT-5, 53, HEIGHT-5, state);
musallambseiso 9:b9ad5e45aebf 57 lcd.drawLine(40, HEIGHT-6, 52, HEIGHT-6, state);
musallambseiso 9:b9ad5e45aebf 58 lcd.drawLine(39, HEIGHT-7, 42, HEIGHT-7, state);
musallambseiso 9:b9ad5e45aebf 59 }
musallambseiso 9:b9ad5e45aebf 60
musallambseiso 9:b9ad5e45aebf 61 void Stats::draw_rocket3(N5110 &lcd, int state)
musallambseiso 9:b9ad5e45aebf 62 {
musallambseiso 9:b9ad5e45aebf 63 lcd.drawLine(56, HEIGHT-3, 59, HEIGHT-3, state);
musallambseiso 9:b9ad5e45aebf 64 lcd.drawLine(57, HEIGHT-4, 69, HEIGHT-4, state);
musallambseiso 9:b9ad5e45aebf 65 lcd.drawLine(58, HEIGHT-5, 70, HEIGHT-5, state);
musallambseiso 9:b9ad5e45aebf 66 lcd.drawLine(57, HEIGHT-6, 69, HEIGHT-6, state);
musallambseiso 9:b9ad5e45aebf 67 lcd.drawLine(56, HEIGHT-7, 59, HEIGHT-7, state);
musallambseiso 9:b9ad5e45aebf 68 }
musallambseiso 9:b9ad5e45aebf 69
musallambseiso 9:b9ad5e45aebf 70 void Stats::check_rocket(N5110 &lcd, int ammo)
musallambseiso 9:b9ad5e45aebf 71 {
musallambseiso 9:b9ad5e45aebf 72 if (ammo == 3)
musallambseiso 9:b9ad5e45aebf 73 {
musallambseiso 9:b9ad5e45aebf 74 draw_rocket1(lcd, 1);
musallambseiso 9:b9ad5e45aebf 75 draw_rocket2(lcd, 1);
musallambseiso 9:b9ad5e45aebf 76 draw_rocket3(lcd, 1);
musallambseiso 9:b9ad5e45aebf 77 }
musallambseiso 9:b9ad5e45aebf 78 else if (ammo == 2)
musallambseiso 9:b9ad5e45aebf 79 {
musallambseiso 9:b9ad5e45aebf 80 draw_rocket1(lcd, 1);
musallambseiso 9:b9ad5e45aebf 81 draw_rocket2(lcd, 1);
musallambseiso 9:b9ad5e45aebf 82 draw_rocket3(lcd, 2);
musallambseiso 9:b9ad5e45aebf 83 }
musallambseiso 9:b9ad5e45aebf 84 else if (ammo == 1)
musallambseiso 9:b9ad5e45aebf 85 {
musallambseiso 9:b9ad5e45aebf 86 draw_rocket1(lcd, 1);
musallambseiso 9:b9ad5e45aebf 87 draw_rocket2(lcd, 2);
musallambseiso 9:b9ad5e45aebf 88 draw_rocket3(lcd, 2);
musallambseiso 9:b9ad5e45aebf 89 }
musallambseiso 9:b9ad5e45aebf 90 else if (ammo == 0)
musallambseiso 9:b9ad5e45aebf 91 {
musallambseiso 9:b9ad5e45aebf 92 draw_rocket1(lcd, 2);
musallambseiso 9:b9ad5e45aebf 93 draw_rocket2(lcd, 2);
musallambseiso 9:b9ad5e45aebf 94 draw_rocket3(lcd, 2);
musallambseiso 9:b9ad5e45aebf 95 }
musallambseiso 9:b9ad5e45aebf 96 }
musallambseiso 9:b9ad5e45aebf 97
musallambseiso 8:b8e8e2f335e1 98 void Stats::check_health(N5110 &lcd, int collisions)
musallambseiso 8:b8e8e2f335e1 99 {
musallambseiso 8:b8e8e2f335e1 100 if (collisions == 0)
musallambseiso 8:b8e8e2f335e1 101 {
musallambseiso 8:b8e8e2f335e1 102 lcd.drawLine(76,41,80,41,1);
musallambseiso 8:b8e8e2f335e1 103 lcd.drawLine(76,42,80,42,1);
musallambseiso 8:b8e8e2f335e1 104 lcd.drawLine(76,43,80,43,1);
musallambseiso 8:b8e8e2f335e1 105 lcd.drawLine(77,44,79,44,1);
musallambseiso 8:b8e8e2f335e1 106 lcd.setPixel(78,45);
musallambseiso 8:b8e8e2f335e1 107 }
musallambseiso 8:b8e8e2f335e1 108 else if (collisions == 1)
musallambseiso 8:b8e8e2f335e1 109 {
musallambseiso 8:b8e8e2f335e1 110 lcd.drawLine(76,42,80,42,1);
musallambseiso 8:b8e8e2f335e1 111 lcd.drawLine(76,43,80,43,1);
musallambseiso 8:b8e8e2f335e1 112 lcd.drawLine(77,44,79,44,1);
musallambseiso 8:b8e8e2f335e1 113 lcd.setPixel(78,45);
musallambseiso 8:b8e8e2f335e1 114 }
musallambseiso 8:b8e8e2f335e1 115 else if (collisions == 2)
musallambseiso 8:b8e8e2f335e1 116 {
musallambseiso 8:b8e8e2f335e1 117 lcd.drawLine(76,43,80,43,1);
musallambseiso 8:b8e8e2f335e1 118 lcd.drawLine(77,44,79,44,1);
musallambseiso 8:b8e8e2f335e1 119 lcd.setPixel(78,45);
musallambseiso 8:b8e8e2f335e1 120 }
musallambseiso 8:b8e8e2f335e1 121 else if (collisions == 3)
musallambseiso 8:b8e8e2f335e1 122 {
musallambseiso 8:b8e8e2f335e1 123 lcd.drawLine(77,44,79,44,1);
musallambseiso 8:b8e8e2f335e1 124 lcd.setPixel(78,45);
musallambseiso 8:b8e8e2f335e1 125 }
musallambseiso 8:b8e8e2f335e1 126 else if (collisions == 4)
musallambseiso 8:b8e8e2f335e1 127 {
musallambseiso 8:b8e8e2f335e1 128 lcd.setPixel(78,45);
musallambseiso 8:b8e8e2f335e1 129 }
musallambseiso 8:b8e8e2f335e1 130 else if (collisions >= 5)
musallambseiso 8:b8e8e2f335e1 131 {
musallambseiso 8:b8e8e2f335e1 132 }
musallambseiso 9:b9ad5e45aebf 133 }
musallambseiso 9:b9ad5e45aebf 134