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

RetroGameEngine/GameObject.h

Committer:
taylorza
Date:
2015-02-16
Revision:
16:f9227904afc4
Parent:
14:b4884a31069e

File content as of revision 16:f9227904afc4:

#ifndef __GAMEOBJECT_H__
#define __GAMEOBJECT_H__

class Scene;
class GameObject
{
public:
    GameObject();

public: 
    void setStartPosition(uint8_t x, uint8_t y);
    void setSpriteId(uint8_t spriteId);
    void setSpeed(uint8_t speed);
    void setCollisionRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h);
    void animate();
    virtual void update();
    virtual void draw();
    
protected:        
    bool moveLeft();
    bool moveRight();
    bool moveUp();
    bool moveDown();
    bool fall();
    
    const GameObject* detectCollision();
    const Block* detectBlock();    
    Rect getCollisionRect();
    
    bool pickupObject();        
    
    bool canGoLeft(uint8_t x, uint8_t y);
    bool canGoRight(uint8_t x, uint8_t y);
    bool canGoUp(uint8_t x, uint8_t y);
    bool canGoDown(uint8_t x, uint8_t y, uint8_t collitionBorder);
    
    bool isOpenBelow();
    bool isOpenBelow(int8_t dx);
    bool isOverLadder();
    bool isLadderAbove();
    bool isLadderBelow();
    bool isLadderLeft();
    bool isLadderRight();
    const Block& getBlockAbove();
    const Block& getBlockBelow();
        
    inline Point& getPosition() {return _position;}    
    inline int8_t getLastXDirection() { return _lastdx; }
    
    void setScene(Scene *pScene) { _pScene = pScene; }
    Scene* getScene() { return _pScene; }
private:  
    uint8_t     _spriteId;
    Point       _position;
    int8_t     _dx;
    int8_t     _dy;
    int8_t     _lastdx;
    int8_t     _lastdy;
    uint8_t    _speed;
    uint8_t    _animationCounter;
    Rect       _collisionRect;
    bool       _flipSprite;
    
    Scene       *_pScene;
    
    friend class Scene;
};

#endif //__GAMEOBJECT_H__