Platform game written for the GHI/OutrageousCircuits RETRO game device. Navigate the caves collecting all the pickups and avoiding the creatures and haunted mine carts that patrol the caves. Oh and remember to watch out for the poisonous plants... This game demonstrates the ability to have multiple animated sprites where the sprites can overlap the background environment. See how the player moves past the fence and climbs the wall in the 3rd screen.

Dependencies:   mbed

Committer:
taylorza
Date:
Mon Feb 16 03:46:57 2015 +0000
Revision:
16:f9227904afc4
Parent:
9:34008d8b1cdf
Added a 4th game screen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
taylorza 9:34008d8b1cdf 1 #include "mbed.h"
taylorza 9:34008d8b1cdf 2 #include "Fix16.h"
taylorza 9:34008d8b1cdf 3 #include "SoundBlock.h"
taylorza 9:34008d8b1cdf 4 #include "SoundChannel.h"
taylorza 9:34008d8b1cdf 5 #include "OneBitSound.h"
taylorza 9:34008d8b1cdf 6
taylorza 9:34008d8b1cdf 7 OneBitSound::OneBitSound(PinName pin) :
taylorza 9:34008d8b1cdf 8 _soundPin(pin)
taylorza 9:34008d8b1cdf 9 {
taylorza 9:34008d8b1cdf 10 _lastPinState = _soundPin;
taylorza 9:34008d8b1cdf 11 _totalElapsed = 0;
taylorza 9:34008d8b1cdf 12 }
taylorza 9:34008d8b1cdf 13
taylorza 9:34008d8b1cdf 14 void OneBitSound::play(uint8_t channel, const SoundBlock soundBlocks[], int count)
taylorza 9:34008d8b1cdf 15 {
taylorza 9:34008d8b1cdf 16 _channels[channel].play(soundBlocks, count);
taylorza 9:34008d8b1cdf 17
taylorza 9:34008d8b1cdf 18 bool nextState;
taylorza 9:34008d8b1cdf 19 bool updated = false;
taylorza 9:34008d8b1cdf 20 uint32_t bit = _soundPin;
taylorza 9:34008d8b1cdf 21 if (_channels[channel].update(nextState)) { bit = (updated ? bit ^ nextState : nextState); updated = true; }
taylorza 9:34008d8b1cdf 22 if (updated) _soundPin = bit;
taylorza 9:34008d8b1cdf 23 }
taylorza 9:34008d8b1cdf 24
taylorza 9:34008d8b1cdf 25 void OneBitSound::update(int elapsedTime)
taylorza 9:34008d8b1cdf 26 {
taylorza 9:34008d8b1cdf 27 _totalElapsed += elapsedTime;
taylorza 9:34008d8b1cdf 28
taylorza 9:34008d8b1cdf 29 if (_totalElapsed >= US_PER_BIT)
taylorza 9:34008d8b1cdf 30 {
taylorza 9:34008d8b1cdf 31 uint32_t bit = 0;
taylorza 9:34008d8b1cdf 32 while (_totalElapsed >= US_PER_BIT)
taylorza 9:34008d8b1cdf 33 {
taylorza 9:34008d8b1cdf 34 bool nextState = false;
taylorza 9:34008d8b1cdf 35 bool updated = false;
taylorza 9:34008d8b1cdf 36
taylorza 9:34008d8b1cdf 37 if (_channels[0].update(nextState)) { bit = (updated ? bit ^ nextState : nextState); updated = true; }
taylorza 9:34008d8b1cdf 38 if (_channels[1].update(nextState)) { bit = (updated ? bit ^ nextState : nextState); updated = true; }
taylorza 9:34008d8b1cdf 39 if (_channels[2].update(nextState)) { bit = (updated ? bit ^ nextState : nextState); updated = true; }
taylorza 9:34008d8b1cdf 40 if (_channels[3].update(nextState)) { bit = (updated ? bit ^ nextState : nextState); updated = true; }
taylorza 9:34008d8b1cdf 41
taylorza 9:34008d8b1cdf 42 if (updated) _soundPin = bit;
taylorza 9:34008d8b1cdf 43
taylorza 9:34008d8b1cdf 44 _totalElapsed -= US_PER_BIT;
taylorza 9:34008d8b1cdf 45 }
taylorza 9:34008d8b1cdf 46 }
taylorza 9:34008d8b1cdf 47 }
taylorza 9:34008d8b1cdf 48
taylorza 9:34008d8b1cdf 49