Retro game that let's the player steer a ball through a hole filled maze. Has multiple levels of increasing difficulty.

Dependencies:   LCD_ST7735 MusicEngine RETRO_BallsAndThings mbed

Ball and Holes

In this game I attempted to create somewhat natural movement of the ball by implementing gravity and friction which combined over time determine the speed of the ball. Playing with the settings (aka. the magic numbers) that are spread out all over game.cpp, gives different effects, such as an icy, rough or liquid-like surface.

It took some time to figure out how to post my very first youtube video. Sorry for the shaky recording. Trying to record the video with my phone while playing the game in one hand was quite challenging, but here it is;

The left and right buttons are used to cheat: restart the current or go to the next level. Up and down control the game-tick. During game-play the robot-button shows the accelerator graph and the ship-button mutes the sound.

BTW. If your ball happens to get stuck, tilting the console in the opposite direction will set it free. For sake of argument: these magnetic wall-ends are in the words of Bob Ross "a happy accident". Since there is no specific code for it, others might call it a bug. As it results in more interesting game-play, I didn't attempt to fix it, but left a comment for those who dare to look at the mess I call code.

Revision:
2:d4de5a5866fe
Parent:
1:c1ee4c699517
Child:
3:ca8b21da67dc
--- a/Game.h	Sun Feb 01 16:21:24 2015 +0000
+++ b/Game.h	Tue Feb 03 19:02:27 2015 +0000
@@ -5,15 +5,17 @@
 #include "Color565.h"
 #include "font_OEM.h"
 #include "LCD_ST7735.h"
+#include "SoundFX.h"
 #include "Accelerometer.h"
 #include "Shapes.h"
 #include "Ball.h"
 #include "Paddle.h"
 
 
-
+#define NUM_BALLS 3
 
-class Game {    
+class Game
+{
     static const char* LOSE_1;
     static const char* LOSE_2;
     static const char* SPLASH_1;
@@ -26,11 +28,8 @@
     static const int PADDLE_WIDTH = 38;
     static const int PADDLE_HEIGHT = 4;
     static const int PADDLE_SPEED = 4;
-    static const int BOUNCE1_SOUND_TICKS = 1;
-    static const int BOUNCE2_SOUND_TICKS = 2;
     static const char I2C_ADDR = 0x1C << 1;
 
-
     DigitalIn left;
     DigitalIn right;
     DigitalIn down;
@@ -39,20 +38,20 @@
     DigitalIn circle; 
     DigitalOut led1;
     DigitalOut led2;
-    PwmOut pwm;
     AnalogIn ain;
     I2C i2c;
     LCD_ST7735 disp;
 
+    SoundFX snd;
     Accelerometer accel;
     Timer tWait;    // timer used for tickcounts
 
     Vector vGravity;
     Ball ball;
     Paddle paddle;
+    Ball aBalls[NUM_BALLS];
 
 //    int paddleX;
-    int pwmTicksLeft;
     int nLives;
     int nScore;
     bool mode;
@@ -62,22 +61,30 @@
     void printDouble(double value, int x, int y);
     
     void initialize();
-    void initializeBall();
-    void initializePaddle();
     
     void drawString(const char* str, int y);
     
+
+    void initializePaddle();
+    void updatePaddle();
 /*
     void clearPaddle();
     void drawPaddle();
 */
-    void updatePaddle();
-
+    //void initializeBall();
+    //void initializeBalls();
+    void setNoBalls();
+    void newBall();
+    void updateBalls();
+    void redrawBalls();
+    int countBalls();
+    void checkBallsCollision();
     
     int checkTilt();
     void checkButtons();
-    void checkCollision();
-    void checkPwm();
+
+    void checkPaddle();
+    //void checkCollision();
     void printf(int x, int y, const char *szFormat, ...);
     void checkLives();