Nemesis game, stats
Stats.cpp@10:c5ef17e93872, 2017-05-02 (annotated)
- Committer:
- musallambseiso
- Date:
- Tue May 02 22:13:28 2017 +0000
- Revision:
- 10:c5ef17e93872
- Parent:
- 9:b9ad5e45aebf
- Child:
- 11:deba1e6f8d78
Added Doxygen, tidied code, added second weapon type (star)
Who changed what in which revision?
User | Revision | Line number | New 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 | 10:c5ef17e93872 | 13 | void Stats::draw_grid(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 | 10:c5ef17e93872 | 22 | void Stats::draw_wave_counter(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 | 10:c5ef17e93872 | 45 | lcd.drawLine(27, HEIGHT-3, 30, HEIGHT-3, state); |
musallambseiso | 10:c5ef17e93872 | 46 | lcd.drawLine(28, HEIGHT-4, 40, HEIGHT-4, state); |
musallambseiso | 10:c5ef17e93872 | 47 | lcd.drawLine(29, HEIGHT-5, 41, HEIGHT-5, state); |
musallambseiso | 10:c5ef17e93872 | 48 | lcd.drawLine(28, HEIGHT-6, 40, HEIGHT-6, state); |
musallambseiso | 10:c5ef17e93872 | 49 | lcd.drawLine(27, HEIGHT-7, 30, 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 | 10:c5ef17e93872 | 54 | lcd.drawLine(42, HEIGHT-3, 45, HEIGHT-3, state); |
musallambseiso | 10:c5ef17e93872 | 55 | lcd.drawLine(43, HEIGHT-4, 55, HEIGHT-4, state); |
musallambseiso | 10:c5ef17e93872 | 56 | lcd.drawLine(44, HEIGHT-5, 56, HEIGHT-5, state); |
musallambseiso | 10:c5ef17e93872 | 57 | lcd.drawLine(43, HEIGHT-6, 55, HEIGHT-6, state); |
musallambseiso | 10:c5ef17e93872 | 58 | lcd.drawLine(42, HEIGHT-7, 45, 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 | 10:c5ef17e93872 | 63 | lcd.drawLine(57, HEIGHT-3, 60, HEIGHT-3, state); |
musallambseiso | 10:c5ef17e93872 | 64 | lcd.drawLine(58, HEIGHT-4, 70, HEIGHT-4, state); |
musallambseiso | 10:c5ef17e93872 | 65 | lcd.drawLine(59, HEIGHT-5, 71, HEIGHT-5, state); |
musallambseiso | 10:c5ef17e93872 | 66 | lcd.drawLine(58, HEIGHT-6, 70, HEIGHT-6, state); |
musallambseiso | 10:c5ef17e93872 | 67 | lcd.drawLine(57, HEIGHT-7, 60, HEIGHT-7, state); |
musallambseiso | 9:b9ad5e45aebf | 68 | } |
musallambseiso | 9:b9ad5e45aebf | 69 | |
musallambseiso | 10:c5ef17e93872 | 70 | |
musallambseiso | 10:c5ef17e93872 | 71 | void Stats::draw_star(N5110 &lcd, int state) |
musallambseiso | 9:b9ad5e45aebf | 72 | { |
musallambseiso | 10:c5ef17e93872 | 73 | lcd.drawLine(20, HEIGHT-6, 24, HEIGHT-6, state); |
musallambseiso | 10:c5ef17e93872 | 74 | lcd.drawLine(20, HEIGHT-4, 24, HEIGHT-4, state); |
musallambseiso | 10:c5ef17e93872 | 75 | lcd.drawLine(21, HEIGHT-3, 21, HEIGHT-7, state); |
musallambseiso | 10:c5ef17e93872 | 76 | lcd.drawLine(23, HEIGHT-3, 23, HEIGHT-7, state); |
musallambseiso | 10:c5ef17e93872 | 77 | lcd.setPixel(20,41); |
musallambseiso | 10:c5ef17e93872 | 78 | lcd.setPixel(20,45); |
musallambseiso | 10:c5ef17e93872 | 79 | lcd.setPixel(24,41); |
musallambseiso | 10:c5ef17e93872 | 80 | lcd.setPixel(24,45); |
musallambseiso | 9:b9ad5e45aebf | 81 | } |
musallambseiso | 9:b9ad5e45aebf | 82 | |
musallambseiso | 10:c5ef17e93872 | 83 | |
musallambseiso | 10:c5ef17e93872 | 84 | |
musallambseiso | 8:b8e8e2f335e1 | 85 | void Stats::check_health(N5110 &lcd, int collisions) |
musallambseiso | 8:b8e8e2f335e1 | 86 | { |
musallambseiso | 8:b8e8e2f335e1 | 87 | if (collisions == 0) |
musallambseiso | 8:b8e8e2f335e1 | 88 | { |
musallambseiso | 8:b8e8e2f335e1 | 89 | lcd.drawLine(76,41,80,41,1); |
musallambseiso | 8:b8e8e2f335e1 | 90 | lcd.drawLine(76,42,80,42,1); |
musallambseiso | 8:b8e8e2f335e1 | 91 | lcd.drawLine(76,43,80,43,1); |
musallambseiso | 8:b8e8e2f335e1 | 92 | lcd.drawLine(77,44,79,44,1); |
musallambseiso | 8:b8e8e2f335e1 | 93 | lcd.setPixel(78,45); |
musallambseiso | 8:b8e8e2f335e1 | 94 | } |
musallambseiso | 8:b8e8e2f335e1 | 95 | else if (collisions == 1) |
musallambseiso | 8:b8e8e2f335e1 | 96 | { |
musallambseiso | 8:b8e8e2f335e1 | 97 | lcd.drawLine(76,42,80,42,1); |
musallambseiso | 8:b8e8e2f335e1 | 98 | lcd.drawLine(76,43,80,43,1); |
musallambseiso | 8:b8e8e2f335e1 | 99 | lcd.drawLine(77,44,79,44,1); |
musallambseiso | 8:b8e8e2f335e1 | 100 | lcd.setPixel(78,45); |
musallambseiso | 8:b8e8e2f335e1 | 101 | } |
musallambseiso | 8:b8e8e2f335e1 | 102 | else if (collisions == 2) |
musallambseiso | 8:b8e8e2f335e1 | 103 | { |
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 == 3) |
musallambseiso | 8:b8e8e2f335e1 | 109 | { |
musallambseiso | 8:b8e8e2f335e1 | 110 | lcd.drawLine(77,44,79,44,1); |
musallambseiso | 8:b8e8e2f335e1 | 111 | lcd.setPixel(78,45); |
musallambseiso | 8:b8e8e2f335e1 | 112 | } |
musallambseiso | 8:b8e8e2f335e1 | 113 | else if (collisions == 4) |
musallambseiso | 8:b8e8e2f335e1 | 114 | { |
musallambseiso | 8:b8e8e2f335e1 | 115 | lcd.setPixel(78,45); |
musallambseiso | 8:b8e8e2f335e1 | 116 | } |
musallambseiso | 8:b8e8e2f335e1 | 117 | else if (collisions >= 5) |
musallambseiso | 8:b8e8e2f335e1 | 118 | { |
musallambseiso | 8:b8e8e2f335e1 | 119 | } |
musallambseiso | 9:b9ad5e45aebf | 120 | } |
musallambseiso | 9:b9ad5e45aebf | 121 | |
musallambseiso | 10:c5ef17e93872 | 122 | void Stats::check_rocket(N5110 &lcd, int ammo) |
musallambseiso | 10:c5ef17e93872 | 123 | { |
musallambseiso | 10:c5ef17e93872 | 124 | if (ammo == 3) { |
musallambseiso | 10:c5ef17e93872 | 125 | draw_rocket1(lcd, 1); |
musallambseiso | 10:c5ef17e93872 | 126 | draw_rocket2(lcd, 1); |
musallambseiso | 10:c5ef17e93872 | 127 | draw_rocket3(lcd, 1); |
musallambseiso | 10:c5ef17e93872 | 128 | } else if (ammo == 2) { |
musallambseiso | 10:c5ef17e93872 | 129 | draw_rocket1(lcd, 1); |
musallambseiso | 10:c5ef17e93872 | 130 | draw_rocket2(lcd, 1); |
musallambseiso | 10:c5ef17e93872 | 131 | draw_rocket3(lcd, 2); |
musallambseiso | 10:c5ef17e93872 | 132 | } else if (ammo == 1) { |
musallambseiso | 10:c5ef17e93872 | 133 | draw_rocket1(lcd, 1); |
musallambseiso | 10:c5ef17e93872 | 134 | draw_rocket2(lcd, 2); |
musallambseiso | 10:c5ef17e93872 | 135 | draw_rocket3(lcd, 2); |
musallambseiso | 10:c5ef17e93872 | 136 | } else if (ammo == 0) { |
musallambseiso | 10:c5ef17e93872 | 137 | draw_rocket1(lcd, 2); |
musallambseiso | 10:c5ef17e93872 | 138 | draw_rocket2(lcd, 2); |
musallambseiso | 10:c5ef17e93872 | 139 | draw_rocket3(lcd, 2); |
musallambseiso | 10:c5ef17e93872 | 140 | } |
musallambseiso | 10:c5ef17e93872 | 141 | } |
musallambseiso | 10:c5ef17e93872 | 142 | |
musallambseiso | 10:c5ef17e93872 | 143 | void Stats::check_star(N5110 &lcd, bool star) |
musallambseiso | 10:c5ef17e93872 | 144 | { |
musallambseiso | 10:c5ef17e93872 | 145 | if (star == true) |
musallambseiso | 10:c5ef17e93872 | 146 | { |
musallambseiso | 10:c5ef17e93872 | 147 | draw_star(lcd, 1); |
musallambseiso | 10:c5ef17e93872 | 148 | } |
musallambseiso | 10:c5ef17e93872 | 149 | else |
musallambseiso | 10:c5ef17e93872 | 150 | { |
musallambseiso | 10:c5ef17e93872 | 151 | draw_star(lcd, 2); |
musallambseiso | 10:c5ef17e93872 | 152 | } |
musallambseiso | 10:c5ef17e93872 | 153 | } |
musallambseiso | 10:c5ef17e93872 | 154 |