-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.cpp
41 lines (35 loc) · 830 Bytes
/
player.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
#include <iostream>
#include "player.hpp"
Player::Player(std::string imagePath)
{
if (!playerTexture.loadFromFile(imagePath))
{
std::cout << "ERROR: Could not load player texture";
}
playerSprite.setTexture(playerTexture);
}
Player::~Player() {}
void Player::drawPlayer(sf::RenderWindow *window)
{
window->draw(Player::playerSprite);
}
void Player::movePlayer(char direction, float moveSpeed)
{
std::cout << "Moving " << direction << moveSpeed << std::endl;
if (direction == 'u')
{
playerSprite.move(0, -moveSpeed);
}
else if (direction == 'd')
{
playerSprite.move(0, moveSpeed);
}
else if (direction == 'l')
{
playerSprite.move(-moveSpeed, 0);
}
else if (direction == 'r')
{
playerSprite.move(moveSpeed, 0);
}
}