Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Abandoned.cpp
- Committer:
- ozy
- Date:
- 2021-04-13
- Revision:
- 0:99b49fd71085
- Child:
- 1:3bdadf6f6dbd
File content as of revision 0:99b49fd71085:
/* void abandoned_function() { // getting joystick coordinates using Vector2D // joystick centered at 0 with (1,0) being utmost right and (-1,0) being utmost left Vector2D coord = joystick.get_coord(); printf("Coord = %f | %f\n", coord.x, coord.y); float x = coord.x; float y = coord.y; loop idea: while nothing pressed, display standsprite while moving right, toggle between runright and midrunright while moving left, toggle between runleft and midrunleft while (x > -0.02 && x < 0.02) { // joystick not moved - we use ± 0.02 to take account of fluctuation in joystick input fighter.draw(lcd, x, 34); // we write 34 as the y-coordinate to place sprite exactly on ground ( 46 - 12(height of sprite) = 34 ) printf("*Coord = %f | %f\n",x, y); lcd.refresh(); } while (x > 0.02) { // Joystick moved to the right // toggle between the 2 move_right animations with a small delay in between to make it smooth fighter.update_forward(x); printf("**Coord = %f | %f\n", x, y); fighter.move_right(lcd, x, 34); wait(0.2); fighter.update_forward(x); fighter.move_right2(lcd, x, 34); wait(0.2); lcd.refresh(); } while (x < -0.02) { // Joystick moved to the left // toggle between the 2 move_left animations with a small delay in between to make it smooth fighter.update_backward(x); printf("***Coord = %f | %f\n", x, y); fighter.move_left(lcd, x, 34); wait(0.2); fighter.update_backward(x); fighter.move_left2(lcd, x, 34); wait(0.2); lcd.refresh(); } } const int logo[17][19] = { { 1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1 }, { 0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0 }, { 0,0,0,0,0,1,0,1,1,1,0,0,0,0,1,0,0,0,0 }, { 0,0,0,0,1,0,1,1,1,1,1,0,0,0,0,1,0,0,0 }, { 0,0,0,1,0,1,1,0,0,1,1,1,1,0,0,0,1,0,0 }, { 0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,0,0,1,0 }, { 0,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0,1,0 }, { 0,0,1,0,1,1,1,0,0,0,1,1,1,1,1,0,0,1,0 }, { 0,0,1,0,1,1,1,1,0,0,0,0,0,1,1,1,0,1,0 }, { 0,0,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0 }, { 0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0 }, { 0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0 }, { 0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0 }, { 0,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0 }, { 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0 }, { 0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0 }, { 1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1 }, }; */