ELEC2645 (2015/16) / Mbed 2 deprecated HarryPetrovicPong

Dependencies:   N5110 mbed

Fork of 2645_Physics_Engine_Example by Craig Evans

Committer:
HarryPetrovic1
Date:
Thu May 05 14:18:21 2016 +0000
Revision:
1:6632d8423c65
Pong

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HarryPetrovic1 1:6632d8423c65 1 #include "mbed.h"
HarryPetrovic1 1:6632d8423c65 2 #include "N5110.h"
HarryPetrovic1 1:6632d8423c65 3 #define BALLRADIUS 2
HarryPetrovic1 1:6632d8423c65 4
HarryPetrovic1 1:6632d8423c65 5
HarryPetrovic1 1:6632d8423c65 6
HarryPetrovic1 1:6632d8423c65 7 // VCC, SCE, RST, D/C, MOSI, SCLK, LED
HarryPetrovic1 1:6632d8423c65 8 N5110 lcd (PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3);
HarryPetrovic1 1:6632d8423c65 9 AnalogIn yin(PTB3); /*!< sets y position of user paddle*/
HarryPetrovic1 1:6632d8423c65 10 DigitalIn select(PTB11);
HarryPetrovic1 1:6632d8423c65 11
HarryPetrovic1 1:6632d8423c65 12
HarryPetrovic1 1:6632d8423c65 13 Ticker game_timer;
HarryPetrovic1 1:6632d8423c65 14
HarryPetrovic1 1:6632d8423c65 15
HarryPetrovic1 1:6632d8423c65 16
HarryPetrovic1 1:6632d8423c65 17 /*!< struct used to store 2D vectors*/
HarryPetrovic1 1:6632d8423c65 18 typedef struct vector_t vector_t; /*!< struct used to store 2D vectors*/
HarryPetrovic1 1:6632d8423c65 19 struct vector_t {
HarryPetrovic1 1:6632d8423c65 20 float x;
HarryPetrovic1 1:6632d8423c65 21 float y;
HarryPetrovic1 1:6632d8423c65 22 };
HarryPetrovic1 1:6632d8423c65 23 /**
HarryPetrovic1 1:6632d8423c65 24
HarryPetrovic1 1:6632d8423c65 25 @file data.h
HarryPetrovic1 1:6632d8423c65 26 @brief A file containing variables and constants
HarryPetrovic1 1:6632d8423c65 27 @brief These variables and constants are then called to be used within the game
HarryPetrovic1 1:6632d8423c65 28 @author Harry Petrovic
HarryPetrovic1 1:6632d8423c65 29 @date May 2016
HarryPetrovic1 1:6632d8423c65 30 */
HarryPetrovic1 1:6632d8423c65 31
HarryPetrovic1 1:6632d8423c65 32 vector_t pos; /*!< Position of the ball*/
HarryPetrovic1 1:6632d8423c65 33 vector_t vel; /*!< Velocity of the ball*/
HarryPetrovic1 1:6632d8423c65 34 vector_t acc; /*!< acceleration of the ball*/
HarryPetrovic1 1:6632d8423c65 35
HarryPetrovic1 1:6632d8423c65 36 float refresh_rate = 200.0; /*!< how often to update display (Hz)*/
HarryPetrovic1 1:6632d8423c65 37 float g_dt = 20.0F/refresh_rate; /*!< global to store time step (F makes it a float, gets rid of compiler warning)*/
HarryPetrovic1 1:6632d8423c65 38 volatile int g_timer_flag = 0;
HarryPetrovic1 1:6632d8423c65 39
HarryPetrovic1 1:6632d8423c65 40 int yp = 0; /*!< y position of user controlled paddle*/
HarryPetrovic1 1:6632d8423c65 41 int yc = 0;/*!< y position of computer controlled paddle*/
HarryPetrovic1 1:6632d8423c65 42 char score1[80]; /*!< Score 1, used for human score*/
HarryPetrovic1 1:6632d8423c65 43 char score2[80]; /*!< Score 2, used for computer score*/
HarryPetrovic1 1:6632d8423c65 44 int playerScore = 0;/*!< Set innitially to 0 at start of game*/
HarryPetrovic1 1:6632d8423c65 45 int computerScore = 0;/*!< Set innitially to 0 at start of game*/
HarryPetrovic1 1:6632d8423c65 46 int Array [84][48]; /*!< Array of Nokia LCD Screen pixels [x][y]*/
HarryPetrovic1 1:6632d8423c65 47 int nx = 84; /*!< integer value of number of pixels on x axis, used for lcd.Clearpixels*/
HarryPetrovic1 1:6632d8423c65 48 int ny = 48; /*!< integer value of number of pixels on y axis, used for lcd.Clearpixels*/
HarryPetrovic1 1:6632d8423c65 49 unsigned char next[84][48]; /*!< used to set buffer for the screen*/
HarryPetrovic1 1:6632d8423c65 50 int difficulty =1; /*!< used in initial menu screen to select difficuly*/