The present code implements a single player squash game, using joystick to move paddle right or left. And checks the current temperature inside the device.
game.h
- Committer:
- bonnyngangu
- Date:
- 2016-05-08
- Revision:
- 1:862da825ba95
- Parent:
- main.cpp@ 0:026fa541af7a
File content as of revision 1:862da825ba95:
#include "mbed.h" #include "N5110.h" // to enable access and use of the N5110 classes. #define DIRECTION_TOLERANCE 0.25 // changing to this value enables altering tolerance of joystick direction #ifndef GAME_H #define GAME_H Ticker pollJoystick;// regular reading of the joystick position. Serial serial(USBTX,USBRX);// Serial for debug //create enumerated type (0,1,2,3 etc. for direction) //could be extended for diagonals etc. enum DirectionName { UP, DOWN, LEFT, RIGHT, CENTRE, UNKNOWN }; typedef struct JoyStick Joystick;// for Joystick structure struct JoyStick { float x; // current x value float x0; // 'centred' x value float y; // current y value float y0; // 'centred' y value int buttonjoystick; /// button state (assume pull-down used, so 1 = pressed, 0 = unpressed) DirectionName direction; /// current direction }; Joystick joystick;// creating struct variables volatile int g_button_flag = 0;// setting the "g_button_flag" original value to Zero. // initialising joystick position. void calibrateJoystick(); // reading the current value of joystick . void updateJoystick(); void button_isr(); int status = 1;// setting the status at the origin. int printFlag = 0;// this sets Flags value to Zero // enabling boolean expression. bool wall = false; bool hit = false; bool bullethit = false; #endif