new mods upon mods by devhammer: - Added paddle control using tilting of the console - Finished mute function - Reduced flickering See game.cpp for full info.

Dependencies:   mbed

Fork of RETRO_Pong_Mod by G. Andrew Duthie

This is a mod of the official Pong game released with the RETRO game console.

Committer:
john_ghielec
Date:
Fri Nov 21 20:13:10 2014 +0000
Revision:
2:6ab46f2e851a
Parent:
1:cd8a3926f263
Child:
3:2f09c90a732d
Added an accelerometer graph when you press the robot.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
john_ghielec 1:cd8a3926f263 1 #include "mbed.h"
john_ghielec 1:cd8a3926f263 2
john_ghielec 1:cd8a3926f263 3 #include "DisplayN18.h"
john_ghielec 1:cd8a3926f263 4
john_ghielec 1:cd8a3926f263 5 #pragma once
john_ghielec 1:cd8a3926f263 6
john_ghielec 1:cd8a3926f263 7 class Game {
john_ghielec 1:cd8a3926f263 8 static const char* LOSE_1;
john_ghielec 1:cd8a3926f263 9 static const char* LOSE_2;
john_ghielec 2:6ab46f2e851a 10 static const char* SPLASH_1;
john_ghielec 2:6ab46f2e851a 11 static const char* SPLASH_2;
john_ghielec 1:cd8a3926f263 12
john_ghielec 1:cd8a3926f263 13 static const int BALL_RADIUS = 3;
john_ghielec 1:cd8a3926f263 14 static const int PADDLE_WIDTH = 38;
john_ghielec 1:cd8a3926f263 15 static const int PADDLE_HEIGHT = 4;
john_ghielec 1:cd8a3926f263 16 static const int PADDLE_SPEED = 4;
john_ghielec 1:cd8a3926f263 17 static const int BOUNCE_SOUND_TICKS = 2;
john_ghielec 2:6ab46f2e851a 18 static const int GRAPH_HEIGHT = 40;
john_ghielec 2:6ab46f2e851a 19 static const int GRAPH_SPACING = 2;
john_ghielec 2:6ab46f2e851a 20 static const char I2C_ADDR = 0x1C << 1;
john_ghielec 1:cd8a3926f263 21
john_ghielec 1:cd8a3926f263 22 int ballX;
john_ghielec 1:cd8a3926f263 23 int ballY;
john_ghielec 1:cd8a3926f263 24 int ballSpeedX;
john_ghielec 1:cd8a3926f263 25 int ballSpeedY;
john_ghielec 1:cd8a3926f263 26 int paddleX;
john_ghielec 1:cd8a3926f263 27 int pwmTicksLeft;
john_ghielec 1:cd8a3926f263 28 int lives;
john_ghielec 2:6ab46f2e851a 29 int graphX;
john_ghielec 2:6ab46f2e851a 30 bool mode;
john_ghielec 2:6ab46f2e851a 31 bool lastUp;
john_ghielec 2:6ab46f2e851a 32 bool lastDown;
john_ghielec 2:6ab46f2e851a 33 unsigned short colors[3];
john_ghielec 2:6ab46f2e851a 34
john_ghielec 1:cd8a3926f263 35 DigitalIn left;
john_ghielec 1:cd8a3926f263 36 DigitalIn right;
john_ghielec 1:cd8a3926f263 37 DigitalIn down;
john_ghielec 1:cd8a3926f263 38 DigitalIn up;
john_ghielec 1:cd8a3926f263 39 DigitalIn square;
john_ghielec 1:cd8a3926f263 40 DigitalIn circle;
john_ghielec 1:cd8a3926f263 41 DigitalOut led1;
john_ghielec 1:cd8a3926f263 42 DigitalOut led2;
john_ghielec 1:cd8a3926f263 43 PwmOut pwm;
john_ghielec 1:cd8a3926f263 44 AnalogIn ain;
john_ghielec 1:cd8a3926f263 45 I2C i2c;
john_ghielec 1:cd8a3926f263 46 DisplayN18 disp;
john_ghielec 1:cd8a3926f263 47
john_ghielec 2:6ab46f2e851a 48 void readRegisters(char address, char* buffer, int len);
john_ghielec 2:6ab46f2e851a 49 int writeRegister(char address, char value);
john_ghielec 2:6ab46f2e851a 50 void getXYZ(double& x, double& y, double& z);
john_ghielec 2:6ab46f2e851a 51 double convert(char* buffer);
john_ghielec 2:6ab46f2e851a 52 void printDouble(double value, int x, int y);
john_ghielec 2:6ab46f2e851a 53
john_ghielec 2:6ab46f2e851a 54 void drawAxes();
john_ghielec 2:6ab46f2e851a 55 void drawPoint(int axis, double value);
john_ghielec 2:6ab46f2e851a 56 void checkGraphReset();
john_ghielec 2:6ab46f2e851a 57
john_ghielec 1:cd8a3926f263 58 void initialize();
john_ghielec 1:cd8a3926f263 59 void initializeBall();
john_ghielec 1:cd8a3926f263 60
john_ghielec 1:cd8a3926f263 61 void drawString(const char* str, int y);
john_ghielec 1:cd8a3926f263 62
john_ghielec 1:cd8a3926f263 63 void clearPaddle();
john_ghielec 1:cd8a3926f263 64 void drawPaddle();
john_ghielec 1:cd8a3926f263 65 void updatePaddle();
john_ghielec 1:cd8a3926f263 66
john_ghielec 1:cd8a3926f263 67 void clearBall();
john_ghielec 1:cd8a3926f263 68 void drawBall();
john_ghielec 1:cd8a3926f263 69 void updateBall();
john_ghielec 1:cd8a3926f263 70
john_ghielec 2:6ab46f2e851a 71 void checkButtons();
john_ghielec 1:cd8a3926f263 72 void checkCollision();
john_ghielec 1:cd8a3926f263 73 void checkPwm();
john_ghielec 1:cd8a3926f263 74 void checkLives();
john_ghielec 1:cd8a3926f263 75
john_ghielec 1:cd8a3926f263 76 public:
john_ghielec 1:cd8a3926f263 77 Game();
john_ghielec 1:cd8a3926f263 78
john_ghielec 1:cd8a3926f263 79 void showSplashScreen();
john_ghielec 1:cd8a3926f263 80 void tick();
john_ghielec 1:cd8a3926f263 81 };