-
Notifications
You must be signed in to change notification settings - Fork 0
/
sprite.cpp
46 lines (38 loc) · 1.08 KB
/
sprite.cpp
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
#include "sprites.h"
Sprite::Sprite() {}
Sprite::~Sprite() {}
void Sprite::Create(int playerid)
{
if (playerid == 1)
{
m_texture.loadFromFile("images/red_tank.png");
m_sprite.setTexture(m_texture);
m_sprite.setPosition(1030,50);
}
if (playerid == 2)
{
m_texture.loadFromFile("images/blue_tank.png");
m_sprite.setTexture(m_texture);
m_sprite.setPosition(1030,370);
}
if (playerid == 3)
{
m_texture.loadFromFile("images/green_tank.png");
m_sprite.setTexture(m_texture);
m_sprite.setPosition(1030,530);
}
if (playerid == 4)
{
m_texture.loadFromFile("images/magenta_tank.png");
m_sprite.setTexture(m_texture);
m_sprite.setPosition(1030,210);
}
}
void Sprite::setPosition(sf::Vector2f position) {m_position=position;}
sf::Vector2f Sprite::getPosition() { return m_position;}
sf::Texture Sprite::getTexture() { return m_texture;}
sf::Sprite Sprite::getSprite() { return m_sprite;}
void Sprite::Render(sf::RenderWindow& l_window)
{
l_window.draw(m_sprite);
}