-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathNormalTank.cpp
More file actions
36 lines (30 loc) · 765 Bytes
/
NormalTank.cpp
File metadata and controls
36 lines (30 loc) · 765 Bytes
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
#include "stdafx.h"
#include "NormalTank.h"
NormalTank::NormalTank(int x, int y, TankType type, std::vector<std::vector<SDL_Texture*>>& vec):
Tank(x, y, type)
{
life = 100;
currentDir = TankMoveDir(rand() % 4);
setTextures(vec);
}
void NormalTank::setTextures(std::vector<std::vector<SDL_Texture*>>& vec)
{
std::vector<SDL_Texture*>::const_iterator it = vec[type].begin();
for (; it != vec[type].end(); ++it)
{
textures.push_back(*it);
}
}
void NormalTank::Draw(SDL_Renderer* renderer)
{
int width = 0, height = 0;
SDL_QueryTexture(textures[currentDir], NULL, NULL, &width, &height);
SDL_Rect rect = {
_x, _y, width, height
};
SDL_RenderCopy(renderer, textures[currentDir], NULL, &rect);
}
NormalTank::~NormalTank(void)
{
// nothing to do
}