-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLobbyScreen.h
More file actions
127 lines (98 loc) 路 2.94 KB
/
Copy pathLobbyScreen.h
File metadata and controls
127 lines (98 loc) 路 2.94 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef _LOBBYSCREEN_H
#define _LOBBYSCREEN_H
#include <QuickSDL/GameEntity.h>
#include <QuickSDL/Graphics.h>
#include <QuickSDL/Texture.h>
#include <headers/Tank.h>
#include <socket/Client.hpp>
#include <string>
using namespace QuickSDL;
class PlayerInfo : public GameEntity {
public:
std::string name;
GameEntity::COLOR color;
bool isThisPlayer;
bool mIsReady;
private:
Texture* mPlayerName;
AnimatedTexture* mBase;
AnimatedTexture* mWeapon;
Texture* mReady;
Texture* mCrown;
bool mIsLeader;
public:
PlayerInfo(std::string _name, GameEntity::COLOR _color, bool isThisPlayer,
int index, bool isReady = false, bool isLeader = false)
: name(_name), color(_color), isThisPlayer(isThisPlayer) {
Pos(Vector2(Graphics::Instance()->SCREEN_WIDTH * 0.5f,
250.0f + index * 40.0f));
if (isThisPlayer) {
mPlayerName = new Texture(name, "Font/ARCADE.TTF", 20, {150, 0, 0});
} else {
mPlayerName = new Texture(name, "Font/ARCADE.TTF", 20, {230, 230, 230});
}
mPlayerName->Parent(this);
mPlayerName->Pos(Vector2(-75.0f, 0.0f));
mIsReady = isReady;
mIsLeader = isLeader;
mBase = new AnimatedTexture(
"Tank/" + colorMap.at(color) + "/Bodies/body_halftrack.png", 0, 0,
Graphics::Instance()->CELL_SIZE, Graphics::Instance()->CELL_SIZE, 2,
0.2f, AnimatedTexture::horizontal);
mBase->Parent(this);
mBase->Pos(Vector2(75.0f, 0.0f));
mBase->Scale(Vector2(0.35f, 0.35f));
mWeapon = new AnimatedTexture(
"Tank/" + colorMap.at(color) + "/Weapons/turret_01_mk1.png", 0, 0,
Graphics::Instance()->CELL_SIZE, Graphics::Instance()->CELL_SIZE, 8,
0.7f, AnimatedTexture::horizontal);
mWeapon->WrapMode(AnimatedTexture::once);
mWeapon->Parent(this);
mWeapon->Pos(Vector2(75.0f, 0.0f));
mWeapon->Scale(Vector2(0.35f, 0.35f));
mReady = new Texture("Check/check.jpg");
mReady->Parent(this);
mReady->Pos(Vector2(150.0f, 0.0f));
mReady->Scale(Vector2(0.04f, 0.04f));
mCrown = new Texture("Menu/queen-crown.png");
mCrown->Parent(this);
mCrown->Pos(Vector2(-150.0f, 0.0f));
mCrown->Scale(Vector2(0.35f, 0.35f));
}
~PlayerInfo() {
delete mPlayerName;
mPlayerName = NULL;
delete mBase;
mBase = NULL;
delete mWeapon;
mWeapon = NULL;
}
void ToggleReady() { mIsReady = !mIsReady; }
void Render() {
mPlayerName->Render();
mBase->Render();
mWeapon->Render();
if (mIsReady) mReady->Render();
if (mIsLeader) mCrown->Render();
}
};
class LobbyScreen : public GameEntity {
private:
static LobbyScreen* sInstance;
InputManager* mInput;
Texture* mTitle;
Texture* mInstruction;
Texture* mRoomCode;
TSS::Client* mClient;
struct PlayerInfo* mPlayerInfo[4];
public:
static LobbyScreen* Instance();
static void Release();
void Update();
void Render();
void SetRoomCode(std::string code);
public:
LobbyScreen();
~LobbyScreen();
};
#endif