GPR5100 - Rollback
Loading...
Searching...
No Matches
game_globals.h
Go to the documentation of this file.
1
5#pragma once
6#include <SFML/Graphics/Color.hpp>
7#include <array>
8
9#include "engine/component.h"
10#include "engine/entity.h"
11#include "graphics/color.h"
12#include "maths/angle.h"
13#include "maths/vec2.h"
14
15
16namespace game
17{
22using PlayerNumber = std::uint8_t;
26constexpr auto INVALID_PLAYER = std::numeric_limits<PlayerNumber>::max();
31enum class ClientId : std::uint16_t {};
32constexpr auto INVALID_CLIENT_ID = ClientId{ 0 };
33using Frame = std::uint32_t;
37constexpr std::uint32_t maxPlayerNmb = 2;
38constexpr short playerHealth = 5;
39constexpr float playerSpeed = 1.0f;
40constexpr core::Degree playerAngularSpeed = core::Degree(90.0f);
41constexpr float playerShootingPeriod = 0.3f;
42constexpr float bulletSpeed = 2.0f;
43constexpr float bulletScale = 0.2f;
44constexpr float bulletPeriod = 3.0f;
45constexpr float playerInvincibilityPeriod = 1.5f;
46constexpr float invincibilityFlashPeriod = 0.5f;
47
51constexpr std::size_t windowBufferSize = 5u * 50u;
52
56constexpr long long startDelay = 3000;
60constexpr std::size_t maxInputNmb = 50;
64constexpr float fixedPeriod = 0.02f; //50fps
65
66
67constexpr std::array<core::Color, std::max(4u, maxPlayerNmb)> playerColors
68{
69 core::Color::red(),
70 core::Color::blue(),
71 core::Color::yellow(),
72 core::Color::cyan()
73};
74
75constexpr std::array<core::Vec2f, std::max(4u, maxPlayerNmb)> spawnPositions
76{
77 core::Vec2f(0,1),
78 core::Vec2f(0,-1),
79 core::Vec2f(1,0),
80 core::Vec2f(-1,0),
81};
82
83constexpr std::array<core::Degree, std::max(4u, maxPlayerNmb)> spawnRotations
84{
85 core::Degree(0.0f),
86 core::Degree(180.0f),
87 core::Degree(-90.0f),
88 core::Degree(90.0f)
89};
90
91enum class ComponentType : core::EntityMask
92{
93 PLAYER_CHARACTER = static_cast<core::EntityMask>(core::ComponentType::OTHER_TYPE),
94 BULLET = static_cast<core::EntityMask>(core::ComponentType::OTHER_TYPE) << 1u,
95 ASTEROID = static_cast<core::EntityMask>(core::ComponentType::OTHER_TYPE) << 2u,
96 PLAYER_INPUT = static_cast<core::EntityMask>(core::ComponentType::OTHER_TYPE) << 3u,
97 DESTROYED = static_cast<core::EntityMask>(core::ComponentType::OTHER_TYPE) << 4u,
98};
99
103using PlayerInput = std::uint8_t;
104
105namespace PlayerInputEnum
106{
107enum PlayerInput : std::uint8_t
108{
109 NONE = 0u,
110 UP = 1u << 0u,
111 DOWN = 1u << 1u,
112 LEFT = 1u << 2u,
113 RIGHT = 1u << 3u,
114 SHOOT = 1u << 4u,
115};
116}
117}
Degree is an utility class that describes degree angles (0 to 360). It can be easily converted to Rad...
Definition: angle.h:56
std::uint32_t EntityMask
EntityMask is the type used to define the bitwise mask of an Entity. It is used to know what Componen...
Definition: entity.h:22
constexpr auto INVALID_PLAYER
INVALID_PLAYER is an integer constant that defines an invalid player number.
Definition: game_globals.h:26
constexpr std::size_t maxInputNmb
maxInputNmb is the number of inputs stored into an PlayerInputPacket
Definition: game_globals.h:60
constexpr std::size_t windowBufferSize
windowBufferSize is the size of input stored by a client. 5 seconds of frame at 50 fps
Definition: game_globals.h:51
ClientId
ClientId is a type used to define the client identification. It is given by the server to clients.
Definition: game_globals.h:31
std::uint8_t PlayerNumber
PlayerNumber is a type used to define the number of the player. Starting from 0 to maxPlayerNmb.
Definition: game_globals.h:22
constexpr long long startDelay
startDelay is the delay to wait before starting a game in milliseconds
Definition: game_globals.h:56
std::uint8_t PlayerInput
PlayerInput is a type defining the input data from a player.
Definition: game_globals.h:103
constexpr float fixedPeriod
fixedPeriod is the period used in seconds to start a new FixedUpdate method in the game::GameManager
Definition: game_globals.h:64
constexpr std::uint32_t maxPlayerNmb
mmaxPlayerNmb is a integer constant that defines the maximum number of player per game
Definition: game_globals.h:37
Color is a struct defining an RGBA color with 4 bytes.
Definition: color.h:12
Vec2f is a utility class that represents a mathematical 2d vector.
Definition: vec2.h:12