Skip to content

Commit ffe82b2

Browse files
committed
feat: tweak the game config and assets
1 parent 76f3346 commit ffe82b2

File tree

9 files changed

+88
-24
lines changed

9 files changed

+88
-24
lines changed

client/src/systems/game/texture_mapper/texture_mapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Texture TextureMapper::MapBulletType(const sdk::game::types::ProjectileType type
2626
return Texture{.name = "enemy_pack", .scale = 2, .rect = {531, 225, 32, 32}};
2727
}
2828
default: {
29-
return Texture{.name = "player", .scale = 1.5, .rect = {300, 121, 32, 10}};
29+
return Texture{.name = "player", .scale = 2, .rect = {227, 278, 10, 8}};
3030
}
3131
}
3232
}

server/game_files/archetypes/enemies/grappler.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"scriptName": "zigzagMovementScript",
5353
"customValues": {
5454
"verticalSpeed": 100.0,
55-
"horizontalSpeed": 80.0,
55+
"horizontalSpeed": 150.0,
5656
"upperLimitOffset": 100.0,
5757
"lowerLimitOffset": 100.0
5858
}

server/game_files/archetypes/enemies/void_eater.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
{
4343
"scriptName": "voidEaterScript",
4444
"customValues": {
45-
"health": 1500.0,
45+
"health": 3000.0,
4646
"scoreIncrease": 2000,
4747
"fireRate": 0.6,
4848
"bulletArchetype": "void_eater_bullet"

server/game_files/archetypes/projectiles/pata_bullet.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"name": "box_collider2d",
2020
"data": {
2121
"size": {
22-
"x": 48,
23-
"y": 15
22+
"x": 20,
23+
"y": 16
2424
},
2525
"collisionLayers": [
2626
4

server/game_files/levels/the_den.json

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,28 @@
66
"maxTime": 15.0,
77
"enemies": [
88
{
9-
"name": "void_eater",
10-
"count": 5
9+
"name": "enemy_pata_normal",
10+
"count": 10
11+
},
12+
{
13+
"name": "grappler",
14+
"count": 2
1115
}
1216
]
1317
},
1418
{
15-
"maxTime": 30.0,
19+
"maxTime": 40.0,
1620
"enemies": [
1721
{
1822
"name": "enemy_pata_normal",
19-
"count": 10
23+
"count": 20
2024
},
2125
{
2226
"name": "grappler",
27+
"count": 5
28+
},
29+
{
30+
"name": "enforcer",
2331
"count": 2
2432
}
2533
]
@@ -29,15 +37,40 @@
2937
"enemies": [
3038
{
3139
"name": "enemy_pata_normal",
32-
"count": 15
40+
"count": 20
3341
},
3442
{
3543
"name": "enemy_pata_big",
36-
"count": 15
44+
"count": 7
3745
},
3846
{
3947
"name": "grappler",
48+
"count": 10
49+
},
50+
{
51+
"name": "electric_shark",
52+
"count": 10
53+
},
54+
{
55+
"name": "enforcer",
56+
"count": 10
57+
}
58+
]
59+
},
60+
{
61+
"maxTime": 20.0,
62+
"enemies": [
63+
{
64+
"name": "void_eater",
65+
"count": 1
66+
},
67+
{
68+
"name": "electric_shark",
4069
"count": 5
70+
},
71+
{
72+
"name": "grappler",
73+
"count": 20
4174
}
4275
]
4376
}

server/game_files/levels/tutorial.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,27 @@
77
"enemies": [
88
{
99
"name": "enemy_pata_normal",
10-
"count": 15
10+
"count": 1
11+
},
12+
{
13+
"name": "enemy_pata_big",
14+
"count": 1
15+
},
16+
{
17+
"name": "grappler",
18+
"count": 1
19+
},
20+
{
21+
"name": "enforcer",
22+
"count": 1
23+
},
24+
{
25+
"name": "void_eater",
26+
"count": 1
27+
},
28+
{
29+
"name": "electric_shark",
30+
"count": 1
1131
}
1232
]
1333
}

server/src/app/room/game_service/game_service.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ int GameService::Run(std::shared_ptr<Room> api) {
6868
std::cerr << e.what() << std::endl;
6969
return EXIT_FAILURE;
7070
}
71+
StartGameClock();
7172
while (gameRunning_) {
7273
ticksManager_.Update();
7374
messageHandler_.Run(registry_, api_, players_);
7475
ExecuteGameLogic();
7576
network::StateBroadcaster::Run(registry_, api_);
7677
ticksManager_.WaitUntilNextTick();
77-
UpdateTotalGameTime();
7878
}
7979
HandleGameEnd();
8080
return EXIT_SUCCESS;
@@ -128,6 +128,7 @@ void GameService::UpdatePlayerScores() {
128128
}
129129

130130
void GameService::HandleGameEnd() {
131+
GetTotalGameTime();
131132
if (win_) {
132133
logger_.Info("Game ended, players won", "🎉");
133134
} else {
@@ -137,6 +138,7 @@ void GameService::HandleGameEnd() {
137138
if (totalScore == 0) {
138139
win_ = false;
139140
}
141+
logger_.Info("Total game time: " + std::to_string(totalGameTime_) + "s", "⏱️");
140142
logger_.Info("Score penalty: " + std::to_string(scorePenalty_), "🔻");
141143
logger_.Info("Total score: " + std::to_string(totalScore), "🏆");
142144
this->api_->EndGame(totalScore, totalGameTime_, win_);
@@ -152,11 +154,6 @@ void GameService::CheckGameEnd() {
152154
}
153155
}
154156

155-
void GameService::UpdateTotalGameTime() {
156-
totalGameTime_ +=
157-
std::chrono::duration_cast<std::chrono::seconds>(ticksManager_.DeltaTime()).count();
158-
}
159-
160157
unsigned int GameService::ComputeTotalScore() const {
161158
unsigned int totalScore = 0;
162159

@@ -198,3 +195,9 @@ void GameService::CheckTooFarEntities() {
198195
}
199196
}
200197
}
198+
199+
void GameService::GetTotalGameTime() {
200+
const auto currentTime = std::chrono::steady_clock::now();
201+
totalGameTime_ =
202+
std::chrono::duration_cast<std::chrono::seconds>(currentTime - startTime_).count();
203+
}

server/src/app/room/game_service/game_service.hpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ class GameService {
9393
*/
9494
void CheckGameEnd();
9595

96-
/**
97-
* @brief Update the total time of the game
98-
*/
99-
void UpdateTotalGameTime();
100-
10196
/**
10297
* @brief Compute the total score of the game
10398
* @return The total score
@@ -109,6 +104,16 @@ class GameService {
109104
*/
110105
void CheckTooFarEntities();
111106

107+
/**
108+
* @brief Start game clock
109+
*/
110+
inline void StartGameClock() { startTime_ = std::chrono::steady_clock::now(); }
111+
112+
/**
113+
* @brief Update total game time
114+
*/
115+
void GetTotalGameTime();
116+
112117
private:
113118
/// @brief Game running flag
114119
bool gameRunning_{true};
@@ -160,5 +165,8 @@ class GameService {
160165

161166
/// @brief Total score of the game
162167
int scorePenalty_{0};
168+
169+
/// @brief Start time of the game
170+
std::chrono::steady_clock::time_point startTime_;
163171
};
164172
} // namespace rtype::server::game

server/src/app/room/game_service/scripts/enemies/enemy_default_script.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "zygarde/src/utils/timer/timer.hpp"
1414

1515
namespace rtype::server::game::scripts {
16-
static constexpr zygarde::core::types::Vector3f kPataProjectileOffsetPosition{-40, 30, 0};
16+
static constexpr zygarde::core::types::Vector3f kPataProjectileOffsetPosition{-30, 30, 0};
1717
}
1818

1919
namespace rtype::server::game::scripts {

0 commit comments

Comments
 (0)