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.

Committer:
maxint
Date:
Tue Feb 03 19:02:27 2015 +0000
Revision:
2:d4de5a5866fe
Parent:
1:c1ee4c699517
Added more balls

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maxint 0:87ab172a74b4 1 #pragma once
maxint 0:87ab172a74b4 2 #include "mbed.h"
maxint 0:87ab172a74b4 3
maxint 0:87ab172a74b4 4 #include "Color565.h"
maxint 1:c1ee4c699517 5 #include "font_OEM.h"
maxint 0:87ab172a74b4 6 #include "LCD_ST7735.h"
maxint 0:87ab172a74b4 7
maxint 0:87ab172a74b4 8 #include "Shapes.h"
maxint 0:87ab172a74b4 9 #include "Vector.h"
maxint 0:87ab172a74b4 10 #include "Physics.h"
maxint 0:87ab172a74b4 11
maxint 0:87ab172a74b4 12 class Ball
maxint 0:87ab172a74b4 13 {
maxint 0:87ab172a74b4 14 public:
maxint 0:87ab172a74b4 15 static const bool fFixed=false;
maxint 2:d4de5a5866fe 16 bool fActive;
maxint 0:87ab172a74b4 17
maxint 2:d4de5a5866fe 18 Ball();
maxint 1:c1ee4c699517 19 Ball(LCD_ST7735* pDisp);
maxint 1:c1ee4c699517 20 void initialize(int X, int Y, int R, uint16_t uColor);
maxint 0:87ab172a74b4 21 void setSpeed(int X, int Y);
maxint 0:87ab172a74b4 22 void changeSpeed(bool fUp);
maxint 1:c1ee4c699517 23 void unmove();
maxint 0:87ab172a74b4 24 void update();
maxint 0:87ab172a74b4 25 void clear();
maxint 0:87ab172a74b4 26 void clearPrev();
maxint 0:87ab172a74b4 27 void draw();
maxint 0:87ab172a74b4 28 void redraw();
maxint 0:87ab172a74b4 29
maxint 0:87ab172a74b4 30 Position pos;
maxint 1:c1ee4c699517 31 int nRadius;
maxint 0:87ab172a74b4 32 Vector vSpeed;
maxint 0:87ab172a74b4 33
maxint 0:87ab172a74b4 34 Circle getBoundingCircle();
maxint 0:87ab172a74b4 35 bool collides(Rectangle r);
maxint 0:87ab172a74b4 36 void Bounce(Vector vBounce);
maxint 0:87ab172a74b4 37
maxint 0:87ab172a74b4 38 private:
maxint 1:c1ee4c699517 39 uint16_t uColor;
maxint 0:87ab172a74b4 40 uint16_t uColorHigh;
maxint 0:87ab172a74b4 41 uint16_t uColorMid;
maxint 0:87ab172a74b4 42 uint16_t uColorLow;
maxint 0:87ab172a74b4 43 LCD_ST7735* pDisp;
maxint 1:c1ee4c699517 44
maxint 1:c1ee4c699517 45 uint16_t dimmedColor(uint16_t uColor);
maxint 0:87ab172a74b4 46 };
maxint 0:87ab172a74b4 47