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

main.cpp

Committer:
taylorza
Date:
2015-01-08
Revision:
8:ad5164d57f0d
Parent:
4:45ff7fc8a431
Child:
9:34008d8b1cdf

File content as of revision 8:ad5164d57f0d:

#include "GameEngine.h"
#include "SoundEffects.h"
#include "SpriteSheet.h"
#include "Player.h"
#include "PatrollingEnemy.h"
#include "BouncingEnemy.h"
#include "Assets.h"
#include "Maps.h"
#include "ScreenIntro.h"
#include "Screen1.h"
#include "Screen2.h"
#include "Screen3.h"

class MyGame : public Game
{
    public:
        MyGame() :
            _screen(-1),
            _intro(true)
        {
            setScene(new ScreenIntro);             
        }
        
    private:
        int _screen;
        
        virtual void completeScreen()
        {
            _intro = false;
            if (_screen == 2)
            {
                increaseSpeed(10);
                addLives(1);
            }
            
            _screen = (_screen + 1) % 3;
            
            Scene *pCur = getScene();
            if (pCur != NULL) delete pCur;
            
            switch(_screen)
            {
                case 0 : setScene(new Screen1); break;
                case 1 : setScene(new Screen2); break;
                case 2 : setScene(new Screen3); break;
            }
        };
        
        virtual void update()
        {
            static bool died = false;
            
            if (getLives() > 0)
            {
                Game::update();
            }                       
            else 
            {
                if (died == false)
                {
                    died = true;
                    PLAY_EFFECT(2, Sound_GameOver);
                }
            }            
        }
        
        virtual void draw()
        {            
            Game::draw();
            
            if (!_intro)
            {
                if (getLives() == 0) Surface.drawBitmap(52, 60, bmpText, 0, 0, 56, 8, Color565::White, Color565::Black);            
                
                Surface.drawBitmap(0, 0, bmpText, 0, 16, 32, 8, Color565::White, Color565::Black);                        
                drawNumber(34, 0, getLives());
                
                Surface.drawBitmap(72, 0, bmpText, 32, 16, 34, 8, Color565::White, Color565::Black);                        
                drawNumber(110, 0, getScore());
            }            
        }
        
    private:
        void drawNumber(int x, int y, int number)
        {
            sprintf(_textBuffer, "%d", number);
            for (char *p = _textBuffer; *p != 0; ++p, x += 8)
            {
                int sx = (*p - 48) * 8;                
                Surface.drawBitmap(x, y, bmpText, sx, 8, 8, 8, Color565::White, Color565::Black);                    
            }
        }        
    
    private:        
        char _textBuffer[15];
        bool _intro;
};

MyGame game;

int main()
{               
    game.run();
}