Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Samus.h"
- #include "../main.h"
- Samus::Samus(sf::RenderWindow& parent) :
- Entity(parent)
- {
- #ifdef _DEBUG
- debugInfo.SetSize(12.f);
- #endif
- }
- void Samus::LoadSprite(const std::string& fileName)
- {
- m_sprite.SetImage(ImageManagerInstance->GetImage(fileName));
- }
- void Samus::SetImage(const sf::Image& image)
- {
- m_sprite.SetImage(image);
- }
- void Samus::Update()
- {
- if (InputManagerInstance == NULL)
- return;
- if (InputManagerInstance->IsKeyDown(sf::Key::Left))
- m_x -= 0.05;
- if (InputManagerInstance->IsKeyDown(sf::Key::Right))
- m_x += 0.05;
- if (InputManagerInstance->IsKeyDown(sf::Key::Up))
- m_y -= 0.05;
- if (InputManagerInstance->IsKeyDown(sf::Key::Down))
- m_y += 0.05;
- m_sprite.SetX(m_x);
- m_sprite.SetY(m_y);
- #ifdef _DEBUG
- debugInfo.SetText("Object Name: " + GetName() + "\nX: " + ToString<int>(GetX()) + "\nY: " + ToString<int>(GetY()));
- debugInfo.SetX(GetX());
- debugInfo.SetY(GetY());
- #endif
- }
- void Samus::Draw()
- {
- m_parent.Draw(m_sprite);
- #ifdef _DEBUG
- m_parent.Draw(debugInfo);
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement