The preloaded firmware shipped on the RETRO

Dependencies:   mbed

Committer:
john_ghielec
Date:
Mon Nov 17 19:51:24 2014 +0000
Revision:
1:cd8a3926f263
Child:
2:6ab46f2e851a
Split game logic out into a game file.

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 1:cd8a3926f263 10 static const char* SPLASH;
john_ghielec 1:cd8a3926f263 11
john_ghielec 1:cd8a3926f263 12 static const int BALL_RADIUS = 3;
john_ghielec 1:cd8a3926f263 13 static const int MAX_BALL_SPEED = 5;
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 1:cd8a3926f263 18
john_ghielec 1:cd8a3926f263 19 int ballX;
john_ghielec 1:cd8a3926f263 20 int ballY;
john_ghielec 1:cd8a3926f263 21 int ballSpeedX;
john_ghielec 1:cd8a3926f263 22 int ballSpeedY;
john_ghielec 1:cd8a3926f263 23 int paddleX;
john_ghielec 1:cd8a3926f263 24 int pwmTicksLeft;
john_ghielec 1:cd8a3926f263 25 int lives;
john_ghielec 1:cd8a3926f263 26
john_ghielec 1:cd8a3926f263 27 DigitalIn left;
john_ghielec 1:cd8a3926f263 28 DigitalIn right;
john_ghielec 1:cd8a3926f263 29 DigitalIn down;
john_ghielec 1:cd8a3926f263 30 DigitalIn up;
john_ghielec 1:cd8a3926f263 31 DigitalIn square;
john_ghielec 1:cd8a3926f263 32 DigitalIn circle;
john_ghielec 1:cd8a3926f263 33 DigitalOut led1;
john_ghielec 1:cd8a3926f263 34 DigitalOut led2;
john_ghielec 1:cd8a3926f263 35 PwmOut pwm;
john_ghielec 1:cd8a3926f263 36 AnalogIn ain;
john_ghielec 1:cd8a3926f263 37 I2C i2c;
john_ghielec 1:cd8a3926f263 38 DisplayN18 disp;
john_ghielec 1:cd8a3926f263 39
john_ghielec 1:cd8a3926f263 40 void initialize();
john_ghielec 1:cd8a3926f263 41 void initializeBall();
john_ghielec 1:cd8a3926f263 42
john_ghielec 1:cd8a3926f263 43 void drawString(const char* str, int y);
john_ghielec 1:cd8a3926f263 44
john_ghielec 1:cd8a3926f263 45 void clearPaddle();
john_ghielec 1:cd8a3926f263 46 void drawPaddle();
john_ghielec 1:cd8a3926f263 47 void updatePaddle();
john_ghielec 1:cd8a3926f263 48
john_ghielec 1:cd8a3926f263 49 void clearBall();
john_ghielec 1:cd8a3926f263 50 void drawBall();
john_ghielec 1:cd8a3926f263 51 void updateBall();
john_ghielec 1:cd8a3926f263 52
john_ghielec 1:cd8a3926f263 53 void checkCollision();
john_ghielec 1:cd8a3926f263 54 void checkPwm();
john_ghielec 1:cd8a3926f263 55 void checkLives();
john_ghielec 1:cd8a3926f263 56
john_ghielec 1:cd8a3926f263 57 public:
john_ghielec 1:cd8a3926f263 58 Game();
john_ghielec 1:cd8a3926f263 59
john_ghielec 1:cd8a3926f263 60 void showSplashScreen();
john_ghielec 1:cd8a3926f263 61 void tick();
john_ghielec 1:cd8a3926f263 62 };