2026-03-14 23:07:56 +01:00

48 lines
879 B
C++

#include "game.hpp"
#include "player.hpp"
#include "openworld.hpp"
game::Game::Game()
{
default_world_ = std::make_shared<OpenWorld>();
}
void game::Game::Update()
{
default_world_->Update(40);
}
void game::Game::FinishFrame()
{
default_world_->FinishFrame();
}
void game::Game::PlayerJoined(Player& player)
{
player.SetWorld(default_world_);
players_.insert(&player);
BroadcastChat(player.GetName() + "^r se připoojil jupí jupí jupííí");
}
void game::Game::PlayerLeft(Player& player)
{
players_.erase(&player);
BroadcastChat(player.GetName() + "^r se vodpojil zmrd");
}
bool game::Game::PlayerInput(Player& player, PlayerInputType type, bool enabled)
{
return false; // not handled here
}
void game::Game::BroadcastChat(const std::string& text)
{
for (auto player : players_)
{
player->SendChat(text);
}
}