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.
Diff: game.h
- Revision:
- 2:603d838c1084
- Parent:
- 1:862da825ba95
diff -r 862da825ba95 -r 603d838c1084 game.h --- a/game.h Sun May 08 21:59:21 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -#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