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

BouncingEnemy.h

Committer:
taylorza
Date:
2015-02-16
Revision:
16:f9227904afc4
Parent:
4:45ff7fc8a431

File content as of revision 16:f9227904afc4:


class BouncingEnemy : public GameObject
{
    public:
        BouncingEnemy(uint8_t spriteId) :            
            _dx(1),
            _dy(1)
        {
            setSpriteId(spriteId);
            setSpeed(1);            
        }
        
        virtual void update()
        {
            if (_dx > 0) 
            {
                if (!moveRight()) 
                {
                    _dx = -1;
                }
            }
            else if (_dx < 0)
            {
                if (!moveLeft()) 
                {
                    _dx = 1;
                }
            }
            
            if (_dy > 0) 
            {
                if (!moveDown()) 
                {
                    _dy = -1;
                }
            }
            else if (_dy < 0)
            {
                if (!moveUp()) 
                {
                    _dy = 1;
                }
            }
            
            animate();
        }
        
    private:        
        int8_t _dx;
        int8_t _dy;
};