Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Fighter.cpp@1:3bdadf6f6dbd, 2021-04-17 (annotated)
- Committer:
- ozy
- Date:
- Sat Apr 17 11:38:39 2021 +0000
- Revision:
- 1:3bdadf6f6dbd
- Parent:
- 0:99b49fd71085
- Child:
- 3:1d99b6ad4f9e
Code Before adding interrupts
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ozy | 0:99b49fd71085 | 1 | #include "Fighter.h" |
ozy | 0:99b49fd71085 | 2 | #include "mbed.h" |
ozy | 0:99b49fd71085 | 3 | |
ozy | 0:99b49fd71085 | 4 | |
ozy | 0:99b49fd71085 | 5 | Fighter::Fighter() {} |
ozy | 0:99b49fd71085 | 6 | |
ozy | 0:99b49fd71085 | 7 | void Fighter::draw(N5110 &lcd, float _x, float _y) { // drawing standing Fighter |
ozy | 0:99b49fd71085 | 8 | |
ozy | 0:99b49fd71085 | 9 | const int standsprite[12][10] = { |
ozy | 0:99b49fd71085 | 10 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 11 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 12 | { 0,0,1,1,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 13 | { 0,0,1,0,1,1,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 14 | { 0,1,1,0,1,1,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 15 | { 0,1,0,0,1,1,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 16 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 17 | { 0,0,1,1,0,0,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 18 | { 0,0,1,0,0,0,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 19 | { 0,1,1,0,0,0,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 20 | { 0,1,0,0,0,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 21 | { 0,1,0,0,0,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 22 | }; |
ozy | 0:99b49fd71085 | 23 | |
ozy | 0:99b49fd71085 | 24 | lcd.drawSprite(_x,_y,12,10,(int *)standsprite); |
ozy | 0:99b49fd71085 | 25 | } |
ozy | 0:99b49fd71085 | 26 | |
ozy | 0:99b49fd71085 | 27 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 28 | |
ozy | 0:99b49fd71085 | 29 | void Fighter::move_left(N5110 &lcd, float _x, float _y){ |
ozy | 0:99b49fd71085 | 30 | const int run_left[12][10] = { |
ozy | 0:99b49fd71085 | 31 | { 0,0,1,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 32 | { 0,0,1,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 33 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 34 | { 0,0,1,0,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 35 | { 1,1,1,0,1,1,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 36 | { 0,0,0,0,1,1,0,0,0,1 }, |
ozy | 0:99b49fd71085 | 37 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 38 | { 0,0,1,1,0,0,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 39 | { 0,1,1,0,0,0,1,1,1,1 }, |
ozy | 0:99b49fd71085 | 40 | { 0,0,1,1,0,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 41 | { 0,0,0,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 42 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 43 | }; |
ozy | 0:99b49fd71085 | 44 | lcd.drawSprite(_x,_y,12,10,(int *)run_left); |
ozy | 0:99b49fd71085 | 45 | } |
ozy | 0:99b49fd71085 | 46 | |
ozy | 0:99b49fd71085 | 47 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 48 | |
ozy | 0:99b49fd71085 | 49 | void Fighter::move_left2(N5110 &lcd, float _x, float _y){ |
ozy | 0:99b49fd71085 | 50 | const int midrun_left[12][10] = { |
ozy | 0:99b49fd71085 | 51 | { 0,0,1,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 52 | { 0,0,1,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 53 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 54 | { 0,0,1,0,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 55 | { 1,1,1,0,1,1,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 56 | { 0,0,0,0,1,1,0,0,0,1 }, |
ozy | 0:99b49fd71085 | 57 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 58 | { 0,0,1,1,0,0,1,1,0,0 }, |
ozy | 1:3bdadf6f6dbd | 59 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 1:3bdadf6f6dbd | 60 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 1:3bdadf6f6dbd | 61 | { 0,0,0,0,1,0,1,0,0,0 }, |
ozy | 1:3bdadf6f6dbd | 62 | { 0,0,0,1,0,0,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 63 | }; |
ozy | 0:99b49fd71085 | 64 | lcd.drawSprite(_x,_y,12,10,(int *)midrun_left); |
ozy | 0:99b49fd71085 | 65 | } |
ozy | 0:99b49fd71085 | 66 | |
ozy | 0:99b49fd71085 | 67 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 68 | |
ozy | 0:99b49fd71085 | 69 | void Fighter::move_right(N5110 &lcd, float _x, float _y) { |
ozy | 0:99b49fd71085 | 70 | |
ozy | 0:99b49fd71085 | 71 | const int run_right[12][10] = { |
ozy | 0:99b49fd71085 | 72 | { 0,0,0,0,0,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 73 | { 0,0,0,0,0,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 74 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 75 | { 0,0,1,1,1,1,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 76 | { 0,1,1,0,1,1,0,1,1,1 }, |
ozy | 0:99b49fd71085 | 77 | { 1,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 78 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 79 | { 0,0,1,1,0,0,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 80 | { 1,1,1,1,0,0,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 81 | { 0,0,0,0,0,0,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 82 | { 0,0,0,0,0,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 83 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 84 | }; |
ozy | 0:99b49fd71085 | 85 | lcd.drawSprite(_x,_y,12,10,(int *)run_right); |
ozy | 0:99b49fd71085 | 86 | } |
ozy | 0:99b49fd71085 | 87 | |
ozy | 0:99b49fd71085 | 88 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 89 | |
ozy | 0:99b49fd71085 | 90 | void Fighter::move_right2(N5110 &lcd, float _x, float _y) { |
ozy | 0:99b49fd71085 | 91 | const int midrun_right[12][10] = { |
ozy | 0:99b49fd71085 | 92 | { 0,0,0,0,0,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 93 | { 0,0,0,0,0,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 94 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 95 | { 0,0,1,1,1,1,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 96 | { 0,1,1,0,1,1,0,1,1,1 }, |
ozy | 0:99b49fd71085 | 97 | { 1,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 98 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 99 | { 0,0,1,1,0,0,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 100 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 101 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 1:3bdadf6f6dbd | 102 | { 0,0,0,1,0,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 103 | { 0,0,1,0,0,0,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 104 | }; |
ozy | 1:3bdadf6f6dbd | 105 | |
ozy | 0:99b49fd71085 | 106 | lcd.drawSprite(_x,_y,12,10,(int *)midrun_right); |
ozy | 0:99b49fd71085 | 107 | } |
ozy | 0:99b49fd71085 | 108 | |
ozy | 0:99b49fd71085 | 109 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 110 | |
ozy | 0:99b49fd71085 | 111 | void Fighter::kick_right(N5110 &lcd, float _x, float _y) { |
ozy | 0:99b49fd71085 | 112 | const int kick[12][10] = { |
ozy | 0:99b49fd71085 | 113 | { 0,1,1,0,0,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 114 | { 0,1,1,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 115 | { 0,0,0,1,1,1,1,0,0,1 }, |
ozy | 0:99b49fd71085 | 116 | { 0,0,1,1,1,0,0,0,1,1 }, |
ozy | 0:99b49fd71085 | 117 | { 0,1,1,1,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 118 | { 0,1,0,0,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 119 | { 1,1,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 120 | { 0,0,0,0,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 121 | { 0,0,0,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 122 | { 0,0,0,1,0,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 123 | { 0,0,1,1,0,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 124 | { 0,0,1,1,0,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 125 | }; |
ozy | 0:99b49fd71085 | 126 | lcd.drawSprite(_x,_y,12,10,(int *)kick); |
ozy | 0:99b49fd71085 | 127 | } |
ozy | 0:99b49fd71085 | 128 | |
ozy | 0:99b49fd71085 | 129 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 130 | |
ozy | 0:99b49fd71085 | 131 | void Fighter::kick_left(N5110 &lcd, float _x, float _y) { |
ozy | 0:99b49fd71085 | 132 | const int kick[12][10] = { |
ozy | 0:99b49fd71085 | 133 | { 0,0,0,0,0,0,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 134 | { 0,0,0,0,1,1,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 135 | { 1,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 136 | { 1,1,0,0,0,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 137 | { 0,0,1,1,1,1,1,1,1,0 }, |
ozy | 0:99b49fd71085 | 138 | { 0,0,0,1,1,1,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 139 | { 0,0,0,0,1,1,0,0,1,1 }, |
ozy | 0:99b49fd71085 | 140 | { 0,0,0,0,0,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 141 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 142 | { 0,0,0,0,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 143 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 144 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 145 | }; |
ozy | 0:99b49fd71085 | 146 | lcd.drawSprite(_x,_y,12,10,(int *)kick); |
ozy | 0:99b49fd71085 | 147 | } |
ozy | 0:99b49fd71085 | 148 | |
ozy | 0:99b49fd71085 | 149 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 150 | |
ozy | 0:99b49fd71085 | 151 | void Fighter::punch_right(N5110 &lcd, float _x, float _y) { |
ozy | 0:99b49fd71085 | 152 | const int punch[12][10] = { |
ozy | 0:99b49fd71085 | 153 | { 0,0,0,0,1,1,0,0,0,1 }, |
ozy | 0:99b49fd71085 | 154 | { 0,0,0,0,1,1,0,0,1,1 }, |
ozy | 0:99b49fd71085 | 155 | { 0,0,1,1,1,1,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 156 | { 0,1,0,0,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 157 | { 0,1,1,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 158 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 159 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 160 | { 0,0,0,1,0,0,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 161 | { 0,0,1,1,0,0,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 162 | { 0,0,1,0,0,0,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 163 | { 0,1,1,0,0,0,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 164 | { 1,1,0,0,0,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 165 | }; |
ozy | 0:99b49fd71085 | 166 | lcd.drawSprite(_x,_y,12,10,(int *)punch); |
ozy | 0:99b49fd71085 | 167 | } |
ozy | 0:99b49fd71085 | 168 | |
ozy | 0:99b49fd71085 | 169 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 170 | |
ozy | 0:99b49fd71085 | 171 | void Fighter::punch_left(N5110 &lcd, float _x, float _y) { |
ozy | 0:99b49fd71085 | 172 | const int punch[12][10] = { |
ozy | 0:99b49fd71085 | 173 | { 1,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 174 | { 1,1,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 175 | { 0,1,1,0,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 176 | { 0,0,1,1,1,1,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 177 | { 0,0,0,0,1,1,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 178 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 179 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 180 | { 0,0,1,1,0,0,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 181 | { 0,0,1,1,0,0,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 182 | { 0,0,0,1,0,0,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 183 | { 0,0,0,1,0,0,0,1,1,0 }, |
ozy | 0:99b49fd71085 | 184 | { 0,0,0,1,1,0,0,0,1,1 }, |
ozy | 0:99b49fd71085 | 185 | }; |
ozy | 0:99b49fd71085 | 186 | lcd.drawSprite(_x,_y,12,10,(int *)punch); |
ozy | 0:99b49fd71085 | 187 | } |
ozy | 0:99b49fd71085 | 188 | |
ozy | 0:99b49fd71085 | 189 | // ************************************************************************ |
ozy | 0:99b49fd71085 | 190 | |
ozy | 0:99b49fd71085 | 191 | void Fighter::guard(N5110 &lcd, float _x, float _y) { |
ozy | 0:99b49fd71085 | 192 | const int guard[12][10] = { |
ozy | 0:99b49fd71085 | 193 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 194 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 195 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 196 | { 0,0,1,0,1,1,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 197 | { 0,0,1,0,1,1,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 198 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 199 | { 0,0,0,0,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 200 | { 0,0,0,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 201 | { 0,0,1,1,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 202 | { 0,1,0,0,0,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 203 | { 0,1,0,0,0,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 204 | { 0,1,0,0,0,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 205 | }; |
ozy | 0:99b49fd71085 | 206 | lcd.drawSprite(_x,_y,12,10,(int *)guard); |
ozy | 0:99b49fd71085 | 207 | } |
ozy | 0:99b49fd71085 | 208 | |
ozy | 0:99b49fd71085 | 209 | |
ozy | 0:99b49fd71085 | 210 | |
ozy | 0:99b49fd71085 | 211 | |
ozy | 0:99b49fd71085 | 212 | |
ozy | 0:99b49fd71085 | 213 |