Advertisement
Al99

SDLGameObject.cpp

Nov 11th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include "SDLGameObject.h"
  2.  
  3. SDLGameObject::SDLGameObject(const LoaderParams* pParams) :
  4. GameObject(pParams), m_position(pParams->getX(), pParams->getY()), m_velocity(0,0), m_acceleration(0,0)
  5. {
  6.     m_width = pParams->getWidth();
  7.     m_height = pParams->getHeight();   
  8.     m_textureID = pParams->getTextureID();
  9.    
  10.     m_currentRow = 1;
  11.     m_currentFrame = 1;
  12. }
  13.  
  14. void SDLGameObject::draw(SDL_Renderer* pRenderer)
  15. {
  16.     TextureManager::Instance()->drawFrame(m_textureID,
  17.     (int) m_position.getX(), (int)m_position.getY(), m_width, m_height,
  18.     m_currentRow, m_currentFrame,
  19.     TheGame::Instance()->getRenderer());
  20. }
  21.  
  22. void SDLGameObject::clean()
  23. {}
  24.  
  25. void SDLGameObject::update()
  26. {
  27.     m_velocity += m_acceleration;
  28.     m_position += m_velocity;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement