이대로 제출해버릴까..
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#include "asteroid/game.h"
|
||||
#include "vulkan_engine/vulkan/engine.h"
|
||||
#include "utils/ConfigManager.h"
|
||||
|
||||
void BeginPlay(veng::Engine& engine) {
|
||||
void BeginPlay(veng::Engine& engine, utils::Snowflake playerID) {
|
||||
std::random_device rd;
|
||||
std::mt19937 gen = std::mt19937(rd());
|
||||
std::uniform_real_distribution<float> jitterDist =
|
||||
@@ -11,6 +12,8 @@ void BeginPlay(veng::Engine& engine) {
|
||||
engine.SpawnLifedModel("player", "player", -1);
|
||||
{
|
||||
std::lock_guard lock(player->modding);
|
||||
if (playerID.snowflake != 0)
|
||||
player->ID = playerID;
|
||||
player->position = glm::vec3(jitterDist(gen), jitterDist(gen), 0.f);
|
||||
player->scale = glm::vec3(.02f);
|
||||
player->colision = true;
|
||||
@@ -46,7 +49,7 @@ void BeginPlay(veng::Engine& engine) {
|
||||
player_flame->needsUpdate = true;
|
||||
}
|
||||
|
||||
std::shared_ptr<veng::Model> const other_player =
|
||||
/*std::shared_ptr<veng::Model> const other_player =
|
||||
engine.SpawnLifedModel("player", "other_player", -1);
|
||||
{
|
||||
std::lock_guard lock(other_player->modding);
|
||||
@@ -74,7 +77,7 @@ void BeginPlay(veng::Engine& engine) {
|
||||
other->shouldBeDestroyed = true;
|
||||
};
|
||||
other_player->colision = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
std::shared_ptr<veng::Model> const camera_lag =
|
||||
engine.SpawnLifedModel("", "camera_lag", -1);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "socket/tcp_socket.h"
|
||||
#include "socket/udp_socket.h"
|
||||
#include "socket/wsa_manager.h"
|
||||
#include "utils/ConfigManager.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/snowflake.h"
|
||||
#include "utils/utils.h"
|
||||
@@ -17,21 +18,21 @@ std::uint8_t CLIENTID = 0;
|
||||
|
||||
std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
||||
Network::WSAManager wsamanager;
|
||||
#if !defined(NDEBUG)
|
||||
utils::setDefaultLogger(spdlog::level::level_enum::debug, "log.log", 1024, 2);
|
||||
#endif
|
||||
|
||||
auto config = utils::ConfigManager::load();
|
||||
utils::setDefaultLogger(config.logLevel, config.logFileName,
|
||||
config.logfileSize, config.logfileCount);
|
||||
|
||||
utils::ThreadPool tp(0);
|
||||
Network::IOCP iocp;
|
||||
iocp.init(&tp, SessionProtocol::TCP);
|
||||
|
||||
Network::Address addr;
|
||||
in6_addr in6addr;
|
||||
|
||||
addr.set(AF_INET6, "::1", 9010);
|
||||
addr.set(config.ipVersion, config.IP, config.Port);
|
||||
|
||||
std::shared_ptr<Network::TCPSocket> TCPSock =
|
||||
std::make_shared<Network::TCPSocket>();
|
||||
TCPSock->init(AF_INET6);
|
||||
std::make_shared<Network::TCPSocket>(config.ipVersion);
|
||||
if (TCPSock->connect(addr) == INVALID_SOCKET) {
|
||||
spdlog::error("connect()");
|
||||
std::exit(EXIT_FAILURE);
|
||||
@@ -61,11 +62,19 @@ std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
||||
engine.LoadModelAsset("assets/bullet.fbx", "bullet");
|
||||
engine.LoadModelAsset("assets/background.fbx", "background");
|
||||
|
||||
engine.BeginPlay = BeginPlay;
|
||||
engine.BeginPlay = [ID64 = config.playerid](veng::Engine& engine) {
|
||||
utils::Snowflake ID;
|
||||
ID.snowflake = ID64;
|
||||
BeginPlay(engine, ID);
|
||||
};
|
||||
engine.Tick = Tick;
|
||||
|
||||
engine.init();
|
||||
|
||||
std::shared_ptr<veng::Model> const player = engine.GetSpawnedObject("player");
|
||||
config.playerid = player->ID.snowflake;
|
||||
utils::ConfigManager::save(config);
|
||||
|
||||
tp.enqueueJob(
|
||||
[engine = &engine, TCPSock](utils::ThreadPool* tp, std::uint32_t __) {
|
||||
engine->ResponseToServerAndRefresh(TCPSock);
|
||||
|
||||
@@ -90,6 +90,7 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
||||
bullet->linear_velocity = player->linear_velocity + forward * 10.f;
|
||||
bullet->position = player->position + forward * player->scale.x * 10.f;
|
||||
bullet->owner = player;
|
||||
bullet->OwnerID = player->ID;
|
||||
bullet->scale = player->scale;
|
||||
bullet->colision = true;
|
||||
bullet->OnColision = [](utils::ThreadPool* thread_pool,
|
||||
|
||||
Reference in New Issue
Block a user