#include "pch.h" #include "Gold.h" Gold::Gold(int x, int y, const Type& type) : Item(x, y) , m_Type{ type } { Init(); Item::CenterInTile(); } Gold::Gold(const Point2f& pos, const Type& type) : Item(pos) , m_Type{ type } { Init(); } void Gold::Init() { switch (m_Type) { case Type::COIN: m_Hitbox.width = 26; m_Hitbox.height = 14; m_HitboxMargin.x = 26; m_HitboxMargin.y = 32; m_SrcRect.left = 8 * m_ClipWidth; m_SrcRect.bottom = m_ClipHeight; m_Amount = 500; break; case Type::THREE_COINS: m_Hitbox.width = 54; m_Hitbox.height = 27; m_HitboxMargin.x = 14; m_HitboxMargin.y = 27; m_SrcRect.left = 9 * m_ClipWidth; m_SrcRect.bottom = m_ClipHeight; m_Amount = 1500; break; case Type::SMALL_CHUNK: m_Hitbox.width = 36 / 2; m_Hitbox.height = 28 / 2; m_HitboxMargin.x = 11; m_HitboxMargin.y = 12.5f; m_SrcRect.left = 11 * m_ClipWidth; m_SrcRect.bottom = m_ClipHeight; m_SpriteRect.width /= 2; m_SpriteRect.height /= 2; m_Amount = 100; break; case Type::BIG_CHUNK: m_Hitbox.width = 36; m_Hitbox.height = 28; m_HitboxMargin.x = 22; m_HitboxMargin.y = 25; m_SrcRect.left = 11 * m_ClipWidth; m_SrcRect.bottom = m_ClipHeight; m_Amount = 500; break; default: break; } } size_t Gold::GetTypeHash() const { return typeid(*this).hash_code(); } Gold::~Gold() { } void Gold::Update(float elapsedSec, const Level& level) { Item::Update(elapsedSec, level); } void Gold::Draw() const { Item::Draw(); } int Gold::GetAmount() const { return m_Amount; } Gold::Type Gold::GetType() const { return m_Type; }