///
/// The base game object
///

#ifndef __GAME_OBJECT_H__
#define __GAME_OBJECT_H__

#include "Position.h"		/// objects need a location
#include "Box.h"		/// objects have a bounding box
#include "Event.h"		/// objects can handle events
#include "Sprite.h"		/// objects (often) have sprites

#define MAX_ALTITUDE 2

class GameObject {

 private:
  int id;	

 protected:
  string type;		        /// user-defined identification
  Position pos;			/// position in the game world
  Box box;			/// bounding box for collisions
  bool is_solid;		/// true if object is solid
  int altitude;			/// -MAX to MAX supported (higher drawn first)
  Sprite *p_sprite;		/// the sprite associated with this object
  bool sprite_center;	        /// true if sprite is centered on object
  int sprite_index;		/// Current index frame for sprite
  int sprite_slowdown;		/// Slowdown rate (1 = no slowdown, 0 = stop)
  int sprite_slowdown_count;    /// Slowdown counter
  int colorbg;
  int colorfg;
  
 public:
  GameObject();
  virtual ~GameObject();
  void setId(int new_id);
  int getId();
  void setType(string new_type);
  string getType();
  void setSolid(bool solid);
  bool isSolid();
  void setPos(Position new_pos);
  Position getPos();
  void setBox(Box new_box);
  Box getBox();
  void setAltitude(int new_altitude);
  int getAltitude();

  ///// Functions many objects will override.
  virtual int eventHandler(Event *e);
  virtual void draw();

  /// Set object sprite to new one.
  /// If set_box is true, set bounding box to size of sprite (default is true).
  void setSprite(Sprite *p_new_sprite);
  void setSprite(Sprite *p_new_sprite, bool set_box);
  Sprite *getSprite();

  /// Indicates if sprite is centered at object Position (pos).
  bool isCentered();
  void setCentered(bool centered);

  /// The index of current Sprite frame to be displayed.
  void setSpriteIndex(int new_sprite_index);
  int getSpriteIndex();

  /// Slows down sprite animations (in multiples of WorldManager frame time).
  void setSpriteSlowdown(int new_sprite_slowdown);
  int getSpriteSlowdown();
  void setSpriteSlowdownCount(int new_sprite_slowdown_count);
  int getSpriteSlowdownCount();

  //print info for this object
  void logDebugInfo();

  //set the color of this object
  void setColor(int bg, int fg);
};
 
#endif // __GAME_OBJECT_H__
