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:
6:e2eead4e53fb
Parent:
5:67e75a4f0b52
Child:
7:6e7b789f4060
--- a/Game.h	Thu Feb 05 14:41:21 2015 +0000
+++ b/Game.h	Sat Feb 28 11:40:39 2015 +0000
@@ -10,10 +10,10 @@
 #include "Accelerometer.h"
 #include "Shapes.h"
 #include "Ball.h"
-#include "Paddle.h"
+#include "Wall.h"
 
 
-#define NUM_BALLS 3
+#define NUM_WALLS 20
 
 class Game
 {
@@ -25,10 +25,7 @@
     //char buf[256];
     
     //static const int BALL_RADIUS = 3;
-    static const int BALL_RADIUS = 6;
-    static const int PADDLE_WIDTH = 38;
-    static const int PADDLE_HEIGHT = 4;
-    static const int PADDLE_SPEED = 4;
+    static const int BALL_RADIUS = 5;
     static const char I2C_ADDR = 0x1C << 1;
 
     DigitalIn left;
@@ -40,7 +37,7 @@
     DigitalOut led1;
     DigitalOut led2;
     AnalogIn ain;
-    I2C i2c;
+    //I2C i2c;
     LCD_ST7735 disp;
 
     SoundFX snd;
@@ -48,17 +45,14 @@
 //    Timer tWait;    // timer used for tickcounts
 
     Vector vGravity;
+    Vector vFriction;
     Ball ball;
-    Paddle paddle;
-    Ball aBalls[NUM_BALLS];
+    Wall aWalls[NUM_WALLS];
 
     bool mode;
+    int nTopWall;
     int nBalls;
     int nScore;
-    bool fDrawPaddle;
-    bool fDrawTopWall;
-    
-    int nTopWall;
 
     bool lastUp;
     bool lastDown;
@@ -67,34 +61,26 @@
     void printDouble(double value, int x, int y);
     
     void initialize();
+    Point getGridPos(char *sPos);
+    void addWall(char *sWall);
+    void drawWalls();
     
     void drawString(const char* str, int y);
+
+    void setNoBall();
+    void newBall();
+    void updateBall();
+    void redrawBall();
+    int countBall();
+    void checkBallCollision();
+    //void redrawTopWall();
     
-
-    void initializePaddle();
-    void updatePaddle();
-    void redrawPaddle();
-/*
-    void clearPaddle();
-    void drawPaddle();
-*/
-    //void initializeBall();
-    //void initializeBalls();
-    void setNoBalls();
-    void newBall();
-    void updateBalls();
-    void redrawBalls();
-    int countBalls();
-    void checkBallsCollision();
-    void redrawTopWall();
-    
-    int checkTilt();
+    void checkTilt();
     void checkButtons();
 
-    void checkPaddle();
     //void checkCollision();
     void printf(int x, int y, const char *szFormat, ...);
-    void checkBalls();
+    //void checkBall();
     
     public:
         Game();