
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.
Fork of RETRO_Pong_Mod by
This is a mod of the official Pong game released with the RETRO game console.
Game.h
- Committer:
- maxint
- Date:
- 2015-01-15
- Revision:
- 4:9ad3bc45b6ce
- Parent:
- 3:2f09c90a732d
File content as of revision 4:9ad3bc45b6ce:
#include "mbed.h" #include "DisplayN18.h" #pragma once class Game { static const char* LOSE_1; static const char* LOSE_2; static const char* SPLASH_1; static const char* SPLASH_2; static const char* LIVES; static const char* SCORE; static const int BALL_RADIUS = 3; static const int BALL_STARTING_SPEED = 3; static const int PADDLE_WIDTH = 38; static const int PADDLE_HEIGHT = 4; static const int PADDLE_SPEED = 5; static const int BOUNCE_SOUND_TICKS = 2; static const int GRAPH_HEIGHT = 40; static const int GRAPH_SPACING = 2; static const char I2C_ADDR = 0x1C << 1; int ballX; int ballXprev; int ballY; int ballYprev; int ballSpeedX; int ballSpeedY; int paddleX; int paddleXprev; int pwmTicksLeft; int lives; int score; int graphX; bool mode; bool lastUp; bool lastDown; bool muted; unsigned short colors[3]; DigitalIn left; DigitalIn right; DigitalIn down; DigitalIn up; DigitalIn square; DigitalIn circle; DigitalOut led1; DigitalOut led2; PwmOut pwm; AnalogIn ain; I2C i2c; DisplayN18 disp; void readRegisters(char address, char* buffer, int len); int writeRegister(char address, char value); void getXYZ(double& x, double& y, double& z); double convert(char* buffer); void printDouble(double value, int x, int y); void drawAxes(); void drawPoint(int axis, double value); void checkGraphReset(); void initialize(); void initializeBall(); void drawString(const char* str, int y); void clearPaddle(); void drawPaddle(); void redrawPaddle(); void updatePaddle(); void clearBall(); void clearBallPrev(); void drawBall(); void redrawBall(); void updateBall(); int checkTilt(); void checkButtons(); void checkCollision(); void checkPwm(); void checkLives(); public: Game(); void showSplashScreen(); void tick(); };