-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSDL_GameObject.cpp
More file actions
74 lines (61 loc) · 1.36 KB
/
Copy pathSDL_GameObject.cpp
File metadata and controls
74 lines (61 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "SDL_GameObject.h"
#include"TextureManager.h"
#include "Game.h"
SDL_GameObject::SDL_GameObject()
: GameObject(), m_position(0, 0), m_velocity(0, 0), m_accelaration(0,0)
{
// m_width = params->GetWidth();
// m_height = params->GetHeight();
// m_textureID = params->GetTextureID();
m_currentFrame = 1;
m_currentRow = 1;
}
SDL_GameObject::~SDL_GameObject()
{
}
void SDL_GameObject::load(const LoaderParams *pParams)
{
m_position = Vector2D(pParams->GetX(), pParams->GetY());
m_velocity = Vector2D(0, 0);
m_accelaration = Vector2D(0, 0);
m_width = pParams->GetWidth();
m_height = pParams->GetHeight();
m_textureID = pParams->GetTextureID();
m_currentRow = 1;
m_currentFrame = 1;
// m_numFrames = pParams->GetNumFrames();
}
void SDL_GameObject::Draw()
{
if (m_velocity.GetX() > 0)
{
TextureManager::Instance()->DrawFrame(m_textureID,
m_position.GetX(),
m_position.GetY(),
m_width,
m_height,
m_currentRow,
m_currentFrame,
Game::Instance()->GetRenderer(),
SDL_FLIP_HORIZONTAL);
}
else
{
TextureManager::Instance()->DrawFrame(m_textureID,
m_position.GetX(),
m_position.GetY(),
m_width,
m_height,
m_currentRow,
m_currentFrame,
Game::Instance()->GetRenderer(),
SDL_FLIP_NONE);
}
}
void SDL_GameObject::Update()
{
m_velocity += m_accelaration;
m_position += m_velocity;
}
void SDL_GameObject::Clean()
{}