Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Abandoned.cpp@0:99b49fd71085, 2021-04-13 (annotated)
- Committer:
- ozy
- Date:
- Tue Apr 13 10:06:02 2021 +0000
- Revision:
- 0:99b49fd71085
- Child:
- 1:3bdadf6f6dbd
Sprite moving and Debugging menu class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ozy | 0:99b49fd71085 | 1 | |
ozy | 0:99b49fd71085 | 2 | /* |
ozy | 0:99b49fd71085 | 3 | void abandoned_function() { |
ozy | 0:99b49fd71085 | 4 | // getting joystick coordinates using Vector2D |
ozy | 0:99b49fd71085 | 5 | // joystick centered at 0 with (1,0) being utmost right and (-1,0) being utmost left |
ozy | 0:99b49fd71085 | 6 | Vector2D coord = joystick.get_coord(); |
ozy | 0:99b49fd71085 | 7 | printf("Coord = %f | %f\n", coord.x, coord.y); |
ozy | 0:99b49fd71085 | 8 | float x = coord.x; |
ozy | 0:99b49fd71085 | 9 | float y = coord.y; |
ozy | 0:99b49fd71085 | 10 | |
ozy | 0:99b49fd71085 | 11 | loop idea: |
ozy | 0:99b49fd71085 | 12 | while nothing pressed, display standsprite |
ozy | 0:99b49fd71085 | 13 | while moving right, toggle between runright and midrunright |
ozy | 0:99b49fd71085 | 14 | while moving left, toggle between runleft and midrunleft |
ozy | 0:99b49fd71085 | 15 | |
ozy | 0:99b49fd71085 | 16 | while (x > -0.02 && x < 0.02) { // joystick not moved - we use ± 0.02 to take account of fluctuation in joystick input |
ozy | 0:99b49fd71085 | 17 | fighter.draw(lcd, x, 34); // we write 34 as the y-coordinate to place sprite exactly on ground ( 46 - 12(height of sprite) = 34 ) |
ozy | 0:99b49fd71085 | 18 | printf("*Coord = %f | %f\n",x, y); |
ozy | 0:99b49fd71085 | 19 | lcd.refresh(); |
ozy | 0:99b49fd71085 | 20 | } |
ozy | 0:99b49fd71085 | 21 | |
ozy | 0:99b49fd71085 | 22 | while (x > 0.02) { // Joystick moved to the right |
ozy | 0:99b49fd71085 | 23 | // toggle between the 2 move_right animations with a small delay in between to make it smooth |
ozy | 0:99b49fd71085 | 24 | fighter.update_forward(x); |
ozy | 0:99b49fd71085 | 25 | printf("**Coord = %f | %f\n", x, y); |
ozy | 0:99b49fd71085 | 26 | fighter.move_right(lcd, x, 34); |
ozy | 0:99b49fd71085 | 27 | wait(0.2); |
ozy | 0:99b49fd71085 | 28 | fighter.update_forward(x); |
ozy | 0:99b49fd71085 | 29 | fighter.move_right2(lcd, x, 34); |
ozy | 0:99b49fd71085 | 30 | wait(0.2); |
ozy | 0:99b49fd71085 | 31 | lcd.refresh(); |
ozy | 0:99b49fd71085 | 32 | } |
ozy | 0:99b49fd71085 | 33 | while (x < -0.02) { // Joystick moved to the left |
ozy | 0:99b49fd71085 | 34 | // toggle between the 2 move_left animations with a small delay in between to make it smooth |
ozy | 0:99b49fd71085 | 35 | fighter.update_backward(x); |
ozy | 0:99b49fd71085 | 36 | printf("***Coord = %f | %f\n", x, y); |
ozy | 0:99b49fd71085 | 37 | fighter.move_left(lcd, x, 34); |
ozy | 0:99b49fd71085 | 38 | wait(0.2); |
ozy | 0:99b49fd71085 | 39 | fighter.update_backward(x); |
ozy | 0:99b49fd71085 | 40 | fighter.move_left2(lcd, x, 34); |
ozy | 0:99b49fd71085 | 41 | wait(0.2); |
ozy | 0:99b49fd71085 | 42 | lcd.refresh(); |
ozy | 0:99b49fd71085 | 43 | } |
ozy | 0:99b49fd71085 | 44 | } |
ozy | 0:99b49fd71085 | 45 | |
ozy | 0:99b49fd71085 | 46 | |
ozy | 0:99b49fd71085 | 47 | const int logo[17][19] = { |
ozy | 0:99b49fd71085 | 48 | |
ozy | 0:99b49fd71085 | 49 | { 1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1 }, |
ozy | 0:99b49fd71085 | 50 | { 0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 51 | { 0,0,0,0,0,1,0,1,1,1,0,0,0,0,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 52 | { 0,0,0,0,1,0,1,1,1,1,1,0,0,0,0,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 53 | { 0,0,0,1,0,1,1,0,0,1,1,1,1,0,0,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 54 | { 0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 55 | { 0,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 56 | { 0,0,1,0,1,1,1,0,0,0,1,1,1,1,1,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 57 | { 0,0,1,0,1,1,1,1,0,0,0,0,0,1,1,1,0,1,0 }, |
ozy | 0:99b49fd71085 | 58 | { 0,0,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 59 | { 0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 60 | { 0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0 }, |
ozy | 0:99b49fd71085 | 61 | { 0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 62 | { 0,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 63 | { 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 64 | { 0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 65 | { 1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1 }, |
ozy | 0:99b49fd71085 | 66 | |
ozy | 0:99b49fd71085 | 67 | }; |
ozy | 0:99b49fd71085 | 68 | */ |