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_
Definition: tb_entity.hpp:47
virtual void OnRender(void) const
virtual void OnUpdate(const float deltaTime)
virtual void OnSimulate(void)
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);
}
Definition: tb_vector.hpp:99
This is the heart of TurtleBrains for game developers to create GameScenes and Entities to interact w...
constexpr const Type & Clamp(const Type &value, const Type &minimumValue, const Type &maximumValue) noexcept
Definition: tb_math.hpp:91
Previous Step :: Next Step