Documentation for C++/SDL 2.0 Tile Engine
Making a simple tile based engine
 All Classes Namespaces Functions Variables Enumerations
Public Member Functions | Protected Attributes | List of all members
GameObject Class Reference

A base class for GameObjects to inherit from. More...

#include <gameobject.h>

Inherited by Button, Npc, Player, and TileBar.

Public Member Functions

virtual void Update ()=0
 Update the game object.
virtual void Move (float deltaT)=0
virtual void Draw (Camera *cam=nullptr)=0
virtual void OnMouseDown ()
 On mouse down events.
virtual void OnMouseUp ()
 On mouse up event.
virtual void OnMouseEnter ()
 On mouse enter.
virtual void OnMouseExit ()
 On mouse exit.
virtual void CheckMouseOver (const Vector2f &pos)
bool GetMouseOver ()
 Return T/F is the mouse is over the object.
bool HasTag (std::string tag)
virtual Json::Value Save ()
virtual void Load (Json::Value val)
void SetCollisionMap (CollisionMap map)
Rectf Box ()
 Get the object's box.

Protected Attributes

Image mImage
Physics mPhysics
 Handle's the objects physics.
std::string mTag
 To store tags to identify the object.

Detailed Description

A base class for GameObjects to inherit from.

Base class for gameobjects, has methods for intialization, updating setting colliison maps, mouse interaction, etc.

Member Function Documentation

void GameObject::CheckMouseOver ( const Vector2f pos)
virtual

Check if mouse entered the object's box Updates mMouseOver accordingly

Parameters
posThe mouse pos to check
virtual void GameObject::Draw ( Camera cam = nullptr)
pure virtual

Draw the gameobject, apply an adjustment for the camera if one is desired

Parameters
camThe camera to adjust for

Implemented in Npc, Player, TileBar, and Button.

bool GameObject::HasTag ( std::string  tag)

Check if the gameobject has the tag

Parameters
tagThe tag to check for
Returns
True if the object has the tag
void GameObject::Load ( Json::Value  val)
virtual

Load the gameobject from a Json::Value The GameObject instance of the function takes care of loading the base object members, physics, image and tags

Parameters
valThe Json::Value to load from

Reimplemented in ObjectButton< T >, Button, TileBar, Npc, and Player.

virtual void GameObject::Move ( float  deltaT)
pure virtual

Move the object

Parameters
deltaTThe elapsed time

Implemented in Button, Npc, Player, and TileBar.

Json::Value GameObject::Save ( )
virtual

Save the gameobject data to a json value and return it The GameObject instance of the function takes care of saving the base object members, physics, image and tags

Returns
Json::Value containing the gameobject data

Reimplemented in Button, ObjectButton< T >, TileBar, Npc, and Player.

void GameObject::SetCollisionMap ( CollisionMap  map)
inline

Set a collision map for the physics member to check against

Parameters
mapThe collision map

The documentation for this class was generated from the following files: