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:
2:d4de5a5866fe
Child:
5:67e75a4f0b52
somehow this version fails. Too much ram usage?

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 3:ca8b21da67dc 6 this->fMute=false;
maxint 2:d4de5a5866fe 7 }
maxint 2:d4de5a5866fe 8
maxint 2:d4de5a5866fe 9 void SoundFX::checkPwm()
maxint 2:d4de5a5866fe 10 {
maxint 3:ca8b21da67dc 11 if(this->fMute || this->pwmTicksLeft == 0)
maxint 2:d4de5a5866fe 12 this->pwm.write(0.0);
maxint 3:ca8b21da67dc 13 else
maxint 3:ca8b21da67dc 14 {
maxint 2:d4de5a5866fe 15 this->pwmTicksLeft--;
maxint 2:d4de5a5866fe 16 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 17 }
maxint 2:d4de5a5866fe 18 }
maxint 2:d4de5a5866fe 19
maxint 2:d4de5a5866fe 20 void SoundFX::reset()
maxint 2:d4de5a5866fe 21 {
maxint 2:d4de5a5866fe 22 this->pwmTicksLeft=0;
maxint 2:d4de5a5866fe 23
maxint 2:d4de5a5866fe 24 this->pwm.period_ms(1);
maxint 2:d4de5a5866fe 25 this->pwm.write(0.00);
maxint 2:d4de5a5866fe 26 }
maxint 2:d4de5a5866fe 27
maxint 3:ca8b21da67dc 28 void SoundFX::setMute(bool fMute)
maxint 3:ca8b21da67dc 29 {
maxint 3:ca8b21da67dc 30 this->fMute=fMute;
maxint 3:ca8b21da67dc 31 }
maxint 3:ca8b21da67dc 32
maxint 3:ca8b21da67dc 33
maxint 3:ca8b21da67dc 34 bool SoundFX::getMute()
maxint 3:ca8b21da67dc 35 {
maxint 3:ca8b21da67dc 36 return(this->fMute);
maxint 3:ca8b21da67dc 37 }
maxint 3:ca8b21da67dc 38
maxint 3:ca8b21da67dc 39
maxint 2:d4de5a5866fe 40 void SoundFX::beep(int nDuration) //nDuration=1
maxint 2:d4de5a5866fe 41 {
maxint 3:ca8b21da67dc 42 if(this->fMute)
maxint 3:ca8b21da67dc 43 return;
maxint 2:d4de5a5866fe 44 this->pwmTicksLeft = nDuration;
maxint 2:d4de5a5866fe 45 }
maxint 2:d4de5a5866fe 46
maxint 2:d4de5a5866fe 47 void SoundFX::beepShort()
maxint 2:d4de5a5866fe 48 {
maxint 3:ca8b21da67dc 49 if(this->fMute)
maxint 3:ca8b21da67dc 50 return;
maxint 2:d4de5a5866fe 51 this->pwm.period_ms(2);
maxint 2:d4de5a5866fe 52 this->pwmTicksLeft = SoundFX::BOUNCE1_SOUND_TICKS;
maxint 2:d4de5a5866fe 53 }
maxint 2:d4de5a5866fe 54
maxint 2:d4de5a5866fe 55 void SoundFX::beepLong()
maxint 2:d4de5a5866fe 56 {
maxint 3:ca8b21da67dc 57 if(this->fMute)
maxint 3:ca8b21da67dc 58 return;
maxint 2:d4de5a5866fe 59 this->pwm.period_ms(1);
maxint 2:d4de5a5866fe 60 this->pwmTicksLeft = SoundFX::BOUNCE2_SOUND_TICKS;
maxint 2:d4de5a5866fe 61 }
maxint 2:d4de5a5866fe 62
maxint 2:d4de5a5866fe 63 void SoundFX::beepLow()
maxint 2:d4de5a5866fe 64 {
maxint 3:ca8b21da67dc 65 if(this->fMute)
maxint 3:ca8b21da67dc 66 return;
maxint 2:d4de5a5866fe 67 this->pwm.period(1.0/220);
maxint 2:d4de5a5866fe 68 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 69 wait_ms(150);
maxint 2:d4de5a5866fe 70 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 71 }
maxint 2:d4de5a5866fe 72
maxint 2:d4de5a5866fe 73 void SoundFX::playTune()
maxint 2:d4de5a5866fe 74 {
maxint 3:ca8b21da67dc 75 if(this->fMute)
maxint 3:ca8b21da67dc 76 return;
maxint 2:d4de5a5866fe 77 this->pwm.period(1.0/220);
maxint 2:d4de5a5866fe 78 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 79 wait_ms(150);
maxint 2:d4de5a5866fe 80 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 81
maxint 2:d4de5a5866fe 82 this->pwm.period(1.0/196);
maxint 2:d4de5a5866fe 83 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 84 wait_ms(150);
maxint 2:d4de5a5866fe 85 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 86
maxint 2:d4de5a5866fe 87 this->pwm.period(1.0/164.81);
maxint 2:d4de5a5866fe 88 this->pwm.write(0.5);
maxint 2:d4de5a5866fe 89 wait_ms(150);
maxint 2:d4de5a5866fe 90 this->pwm.write(0.0);
maxint 2:d4de5a5866fe 91 }