Now we can add awesome things to the game. [documentation still in progress, need to write a full sample project]
basket_entity.h
#ifndef _EggDropExample_BasketEntity_h_
#define _EggDropExample_BasketEntity_h_
#include "turtle_brains/tb_game_kit.h"
{
public:
BasketEntity(void);
virtual ~BasketEntity(void);
protected:
virtual void OnAdded(void) override;
virtual void OnRemoved(void) override;
virtual void OnUpdate(
const float deltaTime)
override;
virtual void OnRender(
void)
const override;
private:
tbGame::Sprite mSprite;
};
#endif _EggDropExample_BasketEntity_h_
basket_entity.cpp
#include "basket_entity.h"
#include "turtle_brains/tb_application_kit.h"
BasketEntity::BasketEntity(void) :
tbGame::Entity(
"BasketEntity"),
mSprite("data/basket.png")
{
mSprite.
SetOrigin(tbGraphics::kAnchorCenter);
AddGraphic(mSprite);
AddBoundingCircle(16.0f);
}
BasketEntity::~BasketEntity(void)
{
}
void BasketEntity::OnAdded(void)
{
tbGame::Entity::OnAdded();
}
void BasketEntity::OnRemoved(void)
{
tbGame::Entity::OnRemoved();
}
void BasketEntity::OnSimulate(void)
{
}
void BasketEntity::OnUpdate(const float deltaTime)
{
const float basketX =
tbMath::Clamp(mousePosition.x, 0.0f, tbGraphics::ScreenWidth());
SetPosition(basketX, tbGraphics::ScreenHeight() - 50.0f);
}
void BasketEntity::OnRender(void) const
{
}
{
tbGame::Entity::OnCollideWith(otherEntity);
}
Previous Step :: Next Step