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:
Wed Feb 04 13:10:36 2015 +0000
Revision:
3:ca8b21da67dc
Parent:
0:87ab172a74b4
somehow this version fails. Too much ram usage?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maxint 0:87ab172a74b4 1 #include "Vector.h"
maxint 0:87ab172a74b4 2
maxint 0:87ab172a74b4 3 Vector::Vector()
maxint 0:87ab172a74b4 4 { // constructor
maxint 0:87ab172a74b4 5 this->set((float)0,(float)0);
maxint 0:87ab172a74b4 6 }
maxint 0:87ab172a74b4 7
maxint 0:87ab172a74b4 8 Vector::Vector(float fX, float fY)
maxint 0:87ab172a74b4 9 {
maxint 0:87ab172a74b4 10 this->set(fX, fY);
maxint 0:87ab172a74b4 11 }
maxint 0:87ab172a74b4 12
maxint 0:87ab172a74b4 13 void Vector::set(float fX, float fY)
maxint 0:87ab172a74b4 14 {
maxint 0:87ab172a74b4 15 x=fX;
maxint 0:87ab172a74b4 16 y=fY;
maxint 0:87ab172a74b4 17 }
maxint 0:87ab172a74b4 18 void Vector::set(int nX, int nY)
maxint 0:87ab172a74b4 19 {
maxint 0:87ab172a74b4 20 this->set((float)nX, (float)nY);
maxint 0:87ab172a74b4 21 }
maxint 0:87ab172a74b4 22
maxint 0:87ab172a74b4 23 float Vector::getSize()
maxint 0:87ab172a74b4 24 { // get the size of the vector
maxint 0:87ab172a74b4 25 return(sqrt(x*x+y*y));
maxint 0:87ab172a74b4 26 }
maxint 0:87ab172a74b4 27
maxint 0:87ab172a74b4 28 bool Vector::isLeft() { return(x<0); }
maxint 0:87ab172a74b4 29 bool Vector::isRight() { return(x>0); }
maxint 0:87ab172a74b4 30 bool Vector::isUp() { return(y<0); }
maxint 0:87ab172a74b4 31 bool Vector::isDown() { return(y>0); }
maxint 0:87ab172a74b4 32
maxint 0:87ab172a74b4 33
maxint 0:87ab172a74b4 34 void Vector::add(float fAdd)
maxint 0:87ab172a74b4 35 { // add the size of the vector by adding to its size
maxint 0:87ab172a74b4 36 float fSize=getSize();
maxint 0:87ab172a74b4 37 float fSizeNew=fSize+fAdd;
maxint 0:87ab172a74b4 38 if(fSize!=0)
maxint 0:87ab172a74b4 39 {
maxint 0:87ab172a74b4 40 x=x * (fSizeNew/fSize);
maxint 0:87ab172a74b4 41 y=y * (fSizeNew/fSize);
maxint 0:87ab172a74b4 42 }
maxint 0:87ab172a74b4 43 else
maxint 0:87ab172a74b4 44 { // in case of zero lenght, default to addition in first quadrant.
maxint 0:87ab172a74b4 45 x=sqrt(0.5 * fAdd * fAdd);
maxint 0:87ab172a74b4 46 y=x;
maxint 0:87ab172a74b4 47 }
maxint 0:87ab172a74b4 48 }
maxint 0:87ab172a74b4 49
maxint 0:87ab172a74b4 50 void Vector::add(Vector vAdd)
maxint 0:87ab172a74b4 51 {
maxint 0:87ab172a74b4 52 x+=vAdd.x;
maxint 0:87ab172a74b4 53 y+=vAdd.y;
maxint 0:87ab172a74b4 54 }
maxint 0:87ab172a74b4 55
maxint 0:87ab172a74b4 56 void Vector::multiply(Vector vMult)
maxint 0:87ab172a74b4 57 { // multiply the vector by means of the other vector
maxint 0:87ab172a74b4 58 x*=vMult.x;
maxint 0:87ab172a74b4 59 y*=vMult.y;
maxint 0:87ab172a74b4 60 }