Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Abandoned.cpp
- Committer:
- ozy
- Date:
- 2021-04-19
- Revision:
- 3:1d99b6ad4f9e
- Parent:
- 1:3bdadf6f6dbd
- Child:
- 6:a1a7dc264fed
File content as of revision 3:1d99b6ad4f9e:
// This file includes abandoned code that was replaced because it did not work /* int get_user_input(int &input) { while (1) { if (buttonA.read() == 1) { input = 1; break; } if (buttonB.read() == 1) { input = 2; break; } if (buttonC.read() == 1) { input = 3; break; } if (buttonD.read() == 1) { input = 4; break; } } return input; } 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 }, }; */ /* void menu_select() { char button = get_user_input(); switch (button) { case 'A': menu.play(lcd); break; case 'B': menu.tutorial(lcd); break; case 'C': menu.options_menu(lcd); break; default: menu.homescreen(lcd); break; } } char get_user_input() { char button; while (buttonA.read() == 1) { button = 'A'; wait(0.2); } while (buttonB.read() == 1) { button = 'B'; wait(0.2); } while (buttonC.read() == 1) { button = 'C'; wait(0.2); } while (buttonD.read() == 1) { button = 'D'; wait(0.2); } pc.printf("Value is %c", button); return button; } */