small refactoring

master
Vectozavr 2021-11-13 22:30:12 +07:00
parent 6cd17ac61f
commit 8f271b1a67
6 changed files with 2722 additions and 19 deletions

View File

@ -13,7 +13,7 @@ using namespace std;
// Read server/client settings and start both.
// If client doesn't connect to the localhost - server doesn't start.
void Shooter::InitNetwork() {
void Shooter::initNetwork() {
std::string clientIp;
sf::Uint16 clientPort;
sf::Uint16 serverPort;
@ -90,13 +90,13 @@ void Shooter::start() {
player->reInitWeapons();
player->translate(Vec3D{0, 0, 0});
camera->translateToPoint(player->position() + Vec3D{0, 1.8, 0});
player->attach(camera);
world->addBody(player);
// connecting to the server
InitNetwork();
initNetwork();
// Waiting for connect and updating server if it's same window
while (client->isWorking() && !client->connected()) {
client->update();
@ -179,6 +179,7 @@ void Shooter::update() {
}
void Shooter::gui() {
sf::Sprite sprite;
sprite.setTexture(*ResourceManager::loadTexture(ShooterConsts::MAIN_MENU_GUI));
sprite.setTextureRect(sf::IntRect(243, 3, 9, 9));
@ -191,9 +192,11 @@ void Shooter::gui() {
// health player stats
drawPlayerStats();
drawStatsTable();
}
void Shooter::drawStatsTable() {
int i = 1;
screen->drawText(client->lastEvent(), Vec2D{10, 10}, 25, sf::Color(0, 0, 0, 100));
@ -214,6 +217,7 @@ void Shooter::drawStatsTable() {
Vec2D{10, 15 + 35.0 * i}, 25, sf::Color(0, 0, 0, 150));
i++;
}
}
void Shooter::drawPlayerStats() {

View File

@ -28,39 +28,25 @@ private:
std::shared_ptr<ShooterClient> client = std::make_shared<ShooterClient>(player);
bool inGame = false;
int fireTraces = 0;
void start() override;
void update() override;
void gui() override;
void play();
void drawPlayerStats();
void drawStatsTable();
void InitNetwork();
void initNetwork();
void spawnPlayer(sf::Uint16 id);
void removePlayer(sf::Uint16 id);
void addFireTrace(const Vec3D &from, const Vec3D &to);
void removeFireTrace(const ObjectNameTag &traceName);
void addBonus(const std::string &bonusName, const Vec3D &position);
void removeBonus(const ObjectNameTag &bonusName);
void addWeapon(std::shared_ptr<Weapon> weapon);
void removeWeapon(std::shared_ptr<Weapon> weapon);
void changeEnemyWeapon(const std::string &weaponName, sf::Uint16 enemyId);
public:

View File

@ -39,6 +39,9 @@ namespace ShooterConsts {
const std::string CUBE_OBJ = "obj/cube.obj";
const std::string MAP_OBJ = "maps/map1.obj";
const std::string BIG_MAP_OBJ = "maps/map2.obj";
const std::string SIMPLE_MAP_OBJ = "maps/map_simple.obj";
const std::string PLANE_MAP_OBJ = "maps/plane.obj";
const std::string MAIN_MENU_BACK = "textures/back.png";
const std::string MAIN_MENU_GUI = "textures/gui.png";

View File

@ -14,7 +14,7 @@ int main() {
//game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR);
//game.create(2048, 1152, ShooterConsts::PROJECT_NAME, false);
//game.create(3072, 1920, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
//game.create(3072, 1920, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR);
return 0;
}

2633
maps/map_simple.obj Normal file

File diff suppressed because it is too large Load Diff

77
maps/plane.obj Normal file
View File

@ -0,0 +1,77 @@
m 000 196 173 255 255
m 001 255 255 255 100
m 002 179 116 122 255
m 003 198 73 231 255
m 004 86 81 125 255
m 005 126 179 231 255
m 006 231 180 162 255
m 007 105 148 231 255
m 008 231 160 111 255
m 009 231 161 90 255
m 010 147 231 139 255
m 011 255 199 179 100
m 012 231 88 85 100
m 013 231 66 78 255
m 014 198 73 231 255
m 016 117 231 150 100
m 017 103 79 100 100
m 018 198 73 231 255
m 019 103 79 231 100
m 020 231 30 217 255
m 021 117 231 150 100
m 022 231 66 78 255
m 023 231 30 217 255
m 024 231 88 85 100
m 025 231 161 90 255
m 026 85 231 139 255
m 027 255 199 179 100
m 028 126 179 231 255
m 029 198 73 231 255
m 030 105 148 231 255
m 031 231 180 162 255
m 032 85 231 139 255
m 033 231 160 111 255
m 034 144 103 84 255
m 035 179 116 122 255
m 036 196 173 255 255
m 037 86 81 125 255
m 038 147 231 139 255
o Cube.006_Cube
v -11.718338 -0.958877 10.910831
v -11.718338 -17.776073 10.910831
v -11.718338 -0.958877 -10.910831
v -11.718338 -17.776073 -10.910831
v 11.718338 -0.958877 10.910831
v 11.718338 -17.776073 10.910831
v 11.718338 -0.958877 -10.910831
v 11.718338 -17.776073 -10.910831
v -11.718338 -0.958877 0.000000
v 0.000000 -0.958877 -10.910831
v 11.718338 -0.958877 0.000000
v 0.000000 -0.958877 10.910831
v 0.000000 -0.958877 0.000000
g Cube.006_Cube_Material.001
usemtl Material.001
s off
f 4 9 3
f 8 10 7
f 6 11 5
f 2 12 1
f 11 13 12
f 4 8 6
f 13 9 1
f 10 3 9
f 7 10 13
f 9 2 1
f 2 9 4
f 10 4 3
f 4 10 8
f 11 8 7
f 8 11 6
f 12 6 5
f 6 12 2
f 11 12 5
f 4 6 2
f 13 1 12
f 10 9 13
f 7 13 11