Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

- [x] Xử lý truyền dòng: 1 điểm
- [x] Cài đặt cơ chế vào/ra socket trên server: 2 điểm
- [x] Đăng ký và quản lý tài khoản: 2 điểm
- [x] Đăng nhập và quản lý phiên: 2 điểm
- [x] Tạo phòng chơi: 1 điểm
- [x] Hiển thị phòng chơi và tham gia chơi: 2 điểm
- [x] Quản lý gameplay online có tương tác: 5-8 điểm
- [x] Xây dựng các màn chơi/chế độ chơi khác nhau: 2 -8 điểm
- [x] Người dùng dừng trò chơi: 2 điểm
- [x] Lưu điểm số và thứ hạng: 2 điểm
- [x] Xây dựng hệ thống xếp hạng: 1-3 điểm
- [x] Giao diện đồ họa: 3 điểm
- [ ] Đăng ký và quản lý tài khoản: 2 điểm
- [ ] Đăng nhập và quản lý phiên: 2 điểm
- [ ] Tạo phòng chơi: 1 điểm
- [ ] Hiển thị phòng chơi và tham gia chơi: 2 điểm
- [ ] Quản lý gameplay online có tương tác: 5-8 điểm
- [ ] Xây dựng các màn chơi/chế độ chơi khác nhau: 2 -8 điểm
- [ ] Người dùng dừng trò chơi: 2 điểm
- [ ] Lưu điểm số và thứ hạng: 2 điểm
- [ ] Xây dựng hệ thống xếp hạng: 1-3 điểm
- [ ] Giao diện đồ họa: 3 điểm
- [ ] Các tính năng khác: 1 - 5 điểm
6 changes: 3 additions & 3 deletions include/QuickSDL/Graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ namespace QuickSDL {
class Graphics {
public:
// The Width of the game's window
const int SCREEN_WIDTH = 1920;
const int SCREEN_WIDTH = 960;
// The Height of the game's window
const int SCREEN_HEIGHT = 1024;
const int SCREEN_HEIGHT = 512;
// The title of the game's window
const char* WINDOW_TITLE = "QuickSDL";
// Cell size used for image
const int CELL_SIZE = 128;
// Cell size used for the map
const int MAP_CELL_SIZE = 64;
const int MAP_CELL_SIZE = 32;

private:
// Needed to make GameManager a singleton class
Expand Down
3 changes: 2 additions & 1 deletion include/headers/LeaderBoardScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class LeaderBoardScreen : public GameEntity {

class LeaderBoardPlayer : public PlayerRanking {
public:
LeaderBoardPlayer(std::string name, int score, int rank);
LeaderBoardPlayer(std::string name, int score, int rank,
bool isThisPlayer = false);
};

#endif
26 changes: 15 additions & 11 deletions include/headers/LobbyScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ class PlayerInfo : public GameEntity {
int index, bool isReady = false, bool isLeader = false)
: name(_name), color(_color), isThisPlayer(isThisPlayer) {
Pos(Vector2(Graphics::Instance()->SCREEN_WIDTH * 0.5f,
500.0f + index * 80.0f));
250.0f + index * 40.0f));

mPlayerName = new Texture(name, "Font/ARCADE.TTF", 40, {230, 230, 230});
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(-150.0f, 0.0f));
mPlayerName->Pos(Vector2(-75.0f, 0.0f));

mIsReady = isReady;
mIsLeader = isLeader;
Expand All @@ -46,27 +50,27 @@ class PlayerInfo : public GameEntity {
Graphics::Instance()->CELL_SIZE, Graphics::Instance()->CELL_SIZE, 2,
0.2f, AnimatedTexture::horizontal);
mBase->Parent(this);
mBase->Pos(Vector2(150.0f, 0.0f));
mBase->Scale(Vector2(0.7f, 0.7f));
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(150.0f, 0.0f));
mWeapon->Scale(Vector2(0.7f, 0.7f));
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(300.0f, 0.0f));
mReady->Scale(Vector2(0.1f, 0.1f));
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(-300.0f, 0.0f));
mCrown->Scale(Vector2(0.75f, 0.75f));
mCrown->Pos(Vector2(-150.0f, 0.0f));
mCrown->Scale(Vector2(0.35f, 0.35f));
}

~PlayerInfo() {
Expand Down
3 changes: 2 additions & 1 deletion include/headers/ResultScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class PlayerRanking : public GameEntity {
AnimatedTexture *mBase, *mWeapon;

public:
PlayerRanking(std::string name, int score, COLOR color);
PlayerRanking(std::string name, int score, COLOR color,
bool isThisPlayer = false);
~PlayerRanking();

void Update();
Expand Down
2 changes: 2 additions & 0 deletions src/entities/Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Base::Base(BASE_POSITION basePos, bool isThisPlayer, COLOR color, bool isBot) {

mTexture = new Texture("Base/eagle.png", 0, 0, 60, 60);
mTexture->Parent(this);
mTexture->Scale(Vector2(0.5f, 0.5f));
AddCollider(new BoxCollider(mTexture->ScaledDimensions()));

mDeathAnimation =
Expand Down Expand Up @@ -143,6 +144,7 @@ void Base::Dead() {
mAnimating = true;
Active(false);
mTank->Dead();
if (mIsBot) mClient->player_dead();
if (mIsThisPlayer) mClient->player_dead();

for (int i = 0; i < 3; i++) {
Expand Down
6 changes: 4 additions & 2 deletions src/entities/Brick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ Brick::Brick() : PhysicEntity() {
mTexture = new AnimatedTexture("Base/brick.png", 0, 0, 16, 16, 3, 1.0f,
AnimatedTexture::horizontal);
mTexture->Parent(this);
mTexture->Scale(Vector2(4.0f, 4.0f));
mTexture->Scale(Vector2(Graphics::Instance()->MAP_CELL_SIZE / 16,
Graphics::Instance()->MAP_CELL_SIZE / 16));

mDeathAnimation =
new AnimatedTexture("Explosion/explosion.png", 0, 0, 256, 256, 8, 0.68f,
AnimatedTexture::horizontal);
mDeathAnimation->Parent(this);
mDeathAnimation->Scale(Vector2(0.25f, 0.25f));
mDeathAnimation->Scale(Vector2(Graphics::Instance()->MAP_CELL_SIZE / 256,
Graphics::Instance()->MAP_CELL_SIZE / 256));
mDeathAnimation->WrapMode(AnimatedTexture::once);

AddCollider(new BoxCollider(mTexture->ScaledDimensions()));
Expand Down
3 changes: 2 additions & 1 deletion src/entities/Bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ Bullet::Bullet(bool isFriendly) : PhysicEntity() {
mTexture = new AnimatedTexture("Bullet/bullet.png", 11 * 32, 0, 32, 32, 4,
0.2f, AnimatedTexture::horizontal);
mTexture->Parent(this);
mTexture->Scale(Vector2(0.25f, 0.25f));
mTexture->Pos(VEC2_ZERO);
mTexture->WrapMode(AnimatedTexture::loop);

mSpeed = 500.0f;
mSpeed = 250.0f;

mDirection = up;

Expand Down
56 changes: 39 additions & 17 deletions src/entities/Tank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@ Tank::Tank(bool isThisPlayer, BASE_POSITION basePos, COLOR color)

switch (basePos) {
case topLeft:
Pos(Vector2(192.0f, mGraphics->MAP_CELL_SIZE));
Pos(Vector2(mGraphics->MAP_CELL_SIZE + mGraphics->CELL_SIZE * 0.5f,
mGraphics->MAP_CELL_SIZE));
break;
case bottomLeft:
Pos(Vector2(192.0f, mGraphics->SCREEN_HEIGHT - mGraphics->MAP_CELL_SIZE));
Pos(Vector2(mGraphics->MAP_CELL_SIZE + mGraphics->CELL_SIZE * 0.5f,
mGraphics->SCREEN_HEIGHT - mGraphics->MAP_CELL_SIZE));
break;
case bottomRight:
Pos(Vector2(mGraphics->SCREEN_WIDTH - 192.0f,
Pos(Vector2(mGraphics->SCREEN_WIDTH -
(mGraphics->MAP_CELL_SIZE + mGraphics->CELL_SIZE * 0.5f),
mGraphics->SCREEN_HEIGHT - mGraphics->MAP_CELL_SIZE));
break;
case topRight:
Pos(Vector2(mGraphics->SCREEN_WIDTH - 192.0f, mGraphics->MAP_CELL_SIZE));
Pos(Vector2(mGraphics->SCREEN_WIDTH -
(mGraphics->MAP_CELL_SIZE + mGraphics->CELL_SIZE * 0.5f),
mGraphics->MAP_CELL_SIZE));
break;
}

Expand All @@ -49,6 +54,7 @@ Tank::Tank(bool isThisPlayer, BASE_POSITION basePos, COLOR color)
Graphics::Instance()->CELL_SIZE, Graphics::Instance()->CELL_SIZE, 2, 0.2f,
AnimatedTexture::horizontal);
mBase->Parent(this);
mBase->Scale(Vector2(0.5f, 0.5f));
mBase->Pos(VEC2_ZERO);

mWeapon = new AnimatedTexture(
Expand All @@ -57,19 +63,21 @@ Tank::Tank(bool isThisPlayer, BASE_POSITION basePos, COLOR color)
AnimatedTexture::horizontal);
mWeapon->WrapMode(AnimatedTexture::once);
mWeapon->Parent(this);
mWeapon->Scale(Vector2(0.5f, 0.5f));
mWeapon->Pos(VEC2_ZERO);

mDeathAnimation =
new AnimatedTexture("Explosion/explosion.png", 0, 0, 256, 256, 8, 0.68f,
AnimatedTexture::horizontal);
mDeathAnimation->Scale(Vector2(0.5f, 0.5f));
mDeathAnimation->Scale(Vector2(mGraphics->MAP_CELL_SIZE / 256.0f,
mGraphics->MAP_CELL_SIZE / 256.0f));
mDeathAnimation->Parent(this);
mDeathAnimation->Pos(VEC2_ZERO);
mDeathAnimation->WrapMode(AnimatedTexture::once);

mMoveSpeed = 100.0f;
mMoveBoundsX = Vector2(50, Graphics::Instance()->SCREEN_WIDTH - 50);
mMoveBoundsY = Vector2(50, Graphics::Instance()->SCREEN_HEIGHT - 50);
mMoveSpeed = 50.0f;
mMoveBoundsX = Vector2(10, Graphics::Instance()->SCREEN_WIDTH - 10);
mMoveBoundsY = Vector2(10, Graphics::Instance()->SCREEN_HEIGHT - 10);

mDirection = DIRECTION::up;
mFireDirection = DIRECTION::up;
Expand All @@ -82,7 +90,7 @@ Tank::Tank(bool isThisPlayer, BASE_POSITION basePos, COLOR color)
}
}

AddCollider(new BoxCollider(Vector2(64.0f, 90.0f)), Vector2(0.0f, -5.0f));
AddCollider(new BoxCollider(Vector2(32.0f, 40.0f)));
}

Tank::~Tank() {
Expand Down Expand Up @@ -168,20 +176,34 @@ void Tank::Shoot() {
mAnimating = true;
switch (mFireDirection) {
case up:
mBullets[i]->Fire(Pos() - Vector2(0.0f, 64.0f), mFireDirection);
mClient->shot_bullet(Pos().x, Pos().y - 64.0f, mFireDirection);
mBullets[i]->Fire(
Pos() - Vector2(0.0f, Graphics::Instance()->MAP_CELL_SIZE),
mFireDirection);
mClient->shot_bullet(Pos().x,
Pos().y - Graphics::Instance()->MAP_CELL_SIZE,
mFireDirection);
break;
case down:
mBullets[i]->Fire(Pos() + Vector2(0.0f, 64.0f), mFireDirection);
mClient->shot_bullet(Pos().x, Pos().y + 64.0f, mFireDirection);
mBullets[i]->Fire(
Pos() + Vector2(0.0f, Graphics::Instance()->MAP_CELL_SIZE),
mFireDirection);
mClient->shot_bullet(Pos().x,
Pos().y + Graphics::Instance()->MAP_CELL_SIZE,
mFireDirection);
break;
case left:
mBullets[i]->Fire(Pos() - Vector2(64.0f, 0.0f), mFireDirection);
mClient->shot_bullet(Pos().x - 64.0f, Pos().y, mFireDirection);
mBullets[i]->Fire(
Pos() - Vector2(Graphics::Instance()->MAP_CELL_SIZE, 0.0f),
mFireDirection);
mClient->shot_bullet(Pos().x - Graphics::Instance()->MAP_CELL_SIZE,
Pos().y, mFireDirection);
break;
case right:
mBullets[i]->Fire(Pos() + Vector2(64.0f, 0.0f), mFireDirection);
mClient->shot_bullet(Pos().x + 64.0f, Pos().y, mFireDirection);
mBullets[i]->Fire(
Pos() + Vector2(Graphics::Instance()->MAP_CELL_SIZE, 0.0f),
mFireDirection);
mClient->shot_bullet(Pos().x + Graphics::Instance()->MAP_CELL_SIZE,
Pos().y, mFireDirection);
break;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void *auto_recv_message() {

int alive_count = 0;
for (int i = 0; i < room->players.size(); i++)
if (room->players[i].status == 1) alive_count++;
if (room->players[i].status != 3) alive_count++;

client->alive_players = alive_count;

Expand Down
Loading