-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.cpp
78 lines (64 loc) · 1.59 KB
/
User.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
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
75
76
77
78
//
// User.cpp
// battleeee
//
// Created by Ingy on 12/29/14.
// Copyright (c) 2014 Ingy. All rights reserved.
//
#include "User.h"
#include <iostream>
#include "ResourcePath.hpp"
using namespace std;
User::User()
{
string enemies = resourcePath()+ "avatarE.png";
string players = resourcePath()+ "avatarP.png";
if (!enemyAvatars.loadFromFile(enemies.c_str()))
{
cout << "Unable to load file for enemy"<< endl;
}
else if(!playerAvatars.loadFromFile(players.c_str()))
{
cout << "Unable to load file for player"<< endl;
}
enemyAvatars.setSmooth(true);
enemyAvatars.setRepeated(false);
playerAvatars.setSmooth(true);
playerAvatars.setRepeated(false);
name =" ";
}
User::~User()
{
}
// setters
void User::setNbOfGPl(int New)
{
nbOfGPl=New;
}
void User::setNbOfGW(int New)
{
nbOfGW=New;
}
void User::setAvatar(int avPosition)//!!! check on number of variables needed
{
avatar.setTextureRect(sf::IntRect(200*(avPosition%5), 200*(avPosition/5), 200, 200)); // depends on the picture used.
}
void User::setAvatarRE()
{
int r = rand()%9+1; // generate a random number according to the number of possible avatars
// then select and avatar depending on the size of the avatar.
avatar.setTextureRect(sf::IntRect(200*(r%5), 200*(r/5), 200, 200));
}// sets a random avatar to be used for the enemy
// getters
int User::getNbOfGL()const
{
return nbOfGPl-nbOfGW;
}
int User::getNbOfGPl()const
{
return nbOfGPl;
}
int User::getNbOfGW()const
{
return nbOfGW;
}