Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include "Samus.h"
  2. #include "../main.h"
  3.  
  4. Samus::Samus(sf::RenderWindow& parent) :
  5.     Entity(parent)
  6. {
  7. #ifdef _DEBUG
  8.     debugInfo.SetSize(12.f);
  9. #endif
  10. }
  11.  
  12. void Samus::LoadSprite(const std::string& fileName)
  13. {
  14.     m_sprite.SetImage(ImageManagerInstance->GetImage(fileName));
  15. }
  16.  
  17. void Samus::SetImage(const sf::Image& image)
  18. {
  19.     m_sprite.SetImage(image);
  20. }
  21.  
  22. void Samus::Update()
  23. {
  24.     if (InputManagerInstance == NULL)
  25.         return;
  26.  
  27.     if (InputManagerInstance->IsKeyDown(sf::Key::Left))
  28.         m_x -= 0.05;
  29.  
  30.     if (InputManagerInstance->IsKeyDown(sf::Key::Right))
  31.         m_x += 0.05;
  32.     if (InputManagerInstance->IsKeyDown(sf::Key::Up))
  33.         m_y -= 0.05;
  34.     if (InputManagerInstance->IsKeyDown(sf::Key::Down))
  35.         m_y += 0.05;
  36.  
  37.     m_sprite.SetX(m_x);
  38.     m_sprite.SetY(m_y);
  39.  
  40. #ifdef _DEBUG
  41.     debugInfo.SetText("Object Name: " + GetName() + "\nX: " + ToString<int>(GetX()) + "\nY: " + ToString<int>(GetY()));
  42.     debugInfo.SetX(GetX());
  43.     debugInfo.SetY(GetY());
  44. #endif
  45. }
  46.  
  47. void Samus::Draw()
  48. {
  49.  
  50.     m_parent.Draw(m_sprite);
  51.  
  52. #ifdef _DEBUG
  53.     m_parent.Draw(debugInfo);
  54. #endif
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement