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
Child:
3:ca8b21da67dc
Added more balls

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maxint 2:d4de5a5866fe 1 #include "SoundFX.h"
maxint 2:d4de5a5866fe 2
maxint 2:d4de5a5866fe 3 SoundFX::SoundFX() : pwm(P0_18)
maxint 2:d4de5a5866fe 4 {
maxint 2:d4de5a5866fe 5 this->pwmTicksLeft=0;
maxint 2:d4de5a5866fe 6 }
maxint 2:d4de5a5866fe 7
maxint 2:d4de5a5866fe 8 void SoundFX::checkPwm()
maxint 2:d4de5a5866fe 9 {
maxint 2:d4de5a5866fe 10 if (this->pwmTicksLeft == 0) {
maxint 2:d4de5a5866fe 11 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 12 }
maxint 2:d4de5a5866fe 13 else {
maxint 2:d4de5a5866fe 14 this->pwmTicksLeft--;
maxint 2:d4de5a5866fe 15 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 16 }
maxint 2:d4de5a5866fe 17 }
maxint 2:d4de5a5866fe 18
maxint 2:d4de5a5866fe 19 void SoundFX::reset()
maxint 2:d4de5a5866fe 20 {
maxint 2:d4de5a5866fe 21 this->pwmTicksLeft=0;
maxint 2:d4de5a5866fe 22
maxint 2:d4de5a5866fe 23 this->pwm.period_ms(1);
maxint 2:d4de5a5866fe 24 this->pwm.write(0.00);
maxint 2:d4de5a5866fe 25 }
maxint 2:d4de5a5866fe 26
maxint 2:d4de5a5866fe 27 void SoundFX::beep(int nDuration) //nDuration=1
maxint 2:d4de5a5866fe 28 {
maxint 2:d4de5a5866fe 29 this->pwmTicksLeft = nDuration;
maxint 2:d4de5a5866fe 30 }
maxint 2:d4de5a5866fe 31
maxint 2:d4de5a5866fe 32 void SoundFX::beepShort()
maxint 2:d4de5a5866fe 33 {
maxint 2:d4de5a5866fe 34 this->pwm.period_ms(2);
maxint 2:d4de5a5866fe 35 this->pwmTicksLeft = SoundFX::BOUNCE1_SOUND_TICKS;
maxint 2:d4de5a5866fe 36 }
maxint 2:d4de5a5866fe 37
maxint 2:d4de5a5866fe 38 void SoundFX::beepLong()
maxint 2:d4de5a5866fe 39 {
maxint 2:d4de5a5866fe 40 this->pwm.period_ms(1);
maxint 2:d4de5a5866fe 41 this->pwmTicksLeft = SoundFX::BOUNCE2_SOUND_TICKS;
maxint 2:d4de5a5866fe 42 }
maxint 2:d4de5a5866fe 43
maxint 2:d4de5a5866fe 44 void SoundFX::beepLow()
maxint 2:d4de5a5866fe 45 {
maxint 2:d4de5a5866fe 46 this->pwm.period(1.0/220);
maxint 2:d4de5a5866fe 47 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 48 wait_ms(150);
maxint 2:d4de5a5866fe 49 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 50 }
maxint 2:d4de5a5866fe 51
maxint 2:d4de5a5866fe 52 void SoundFX::playTune()
maxint 2:d4de5a5866fe 53 {
maxint 2:d4de5a5866fe 54 this->pwm.period(1.0/220);
maxint 2:d4de5a5866fe 55 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 56 wait_ms(150);
maxint 2:d4de5a5866fe 57 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 58
maxint 2:d4de5a5866fe 59 this->pwm.period(1.0/196);
maxint 2:d4de5a5866fe 60 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 61 wait_ms(150);
maxint 2:d4de5a5866fe 62 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 63
maxint 2:d4de5a5866fe 64 this->pwm.period(1.0/164.81);
maxint 2:d4de5a5866fe 65 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 66 wait_ms(150);
maxint 2:d4de5a5866fe 67 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 68 }