Files
invoictoafpsgn/main.cpp
T
2026-10-18 12:27:54 -04:00

171 lines
8.5 KiB
C++

/*
______ __ __ __ __ ______ ______ ______ ________ ______ ______ __ __
| \| \ | \| \ | \ / \ | \ / \| \ / \ / \ | \ | \
\$$$$$$| $$\ | $$| $$ | $$| $$$$$$\ \$$$$$$| $$$$$$\\$$$$$$$$| $$$$$$\| $$$$$$\| $$ | $$
| $$ | $$$\| $$| $$ | $$| $$ | $$ | $$ | $$ \$$ | $$ | $$ | $$| $$__| $$| $$__| $$
| $$ | $$$$\ $$ \$$\ / $$| $$ | $$ | $$ | $$ | $$ | $$ | $$| $$ $$| $$ $$
| $$ | $$\$$ $$ \$$\ $$ | $$ | $$ | $$ | $$ __ | $$ | $$ | $$| $$$$$$$$| $$$$$$$$
_| $$_ | $$ \$$$$ \$$ $$ | $$__/ $$ _| $$_ | $$__/ \ | $$ | $$__/ $$| $$ | $$| $$ | $$
| $$ \| $$ \$$$ \$$$ \$$ $$| $$ \ \$$ $$ | $$ \$$ $$| $$ | $$| $$ | $$
\$$$$$$ \$$ \$$ \$ \$$$$$$ \$$$$$$ \$$$$$$ \$$ \$$$$$$ \$$ \$$ \$$ \$$
*/
/*
+*%@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%*%@@@@@@@%%@@@@@@@%%######%%%%%%@@@@@@%%@@@@@@@@@@@@@@@@%+=*%%@@@%%
=#@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*#@@@@@@%**#%##*+================+%@@@%@@@@@@@@@@@@@@@@@%+-=#%%%%%%
=#@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#%@@@@@@#========--------=========+%@@@@@@@@@@@@@@@@@@@@%*:-*%%%%##
=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@#%@@@@@@*=--------------===========*@@@@@@@@@@@@@@@@@@@@@#-:=#%%%##
+%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@%%@@@@@%*=------------=====--======*%@@@@@@@@@@@@@@@@@@@@%=:-*%%%%%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%#***%@@%+------------------------==#@@@@@@@@@@@@@@@@@@@@@%+::+#%%%@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@%+==++#%#=---=++++==-----------=====%@@@@@@@@@@@@@@@@@@@@@@*-:=*%%@@
%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@%*=-+*++#*==+*###%%%#*==----=+##%%#++%@@@@@@@@@@@@@@@@@@@@@@#-:-+#%%@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@%+::+**=+==+*###****###+===+#%@%%##**%@@@@@@@@@@@@@@@@@@@@@@%=::=*###
@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#=:-+=::--=======+***++++**#######*#%@@@@@@@@@@@@@@@@@@@@@@@+::-+#**
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#+---::--------====+==++***++==+++*%@@@@@@@@@@@@@@@@@@@@@@@#-.:=***
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#+:..-=================++========+*%@@@@@@@@@@@@@@@@@@@@@@%=::-+++
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*+-.:=+++==============++++++++==+#@@@@@@@@@@@@@@@@@@@@@@%+::-=+#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%%%%#*=::-+=---===========+++*++**+==+#@@@@@@@@@@@@@@@@@@@@@@@*-::-+#
%%%%%%%%%%%%%%%%@@@%%%%%%%@@@@@%%%%%*=:.:=+**+=-------=======--=+===*%@@@@@@@@@@@@@@@@@@@@@@@#=::-=*
%%%%%%%%%%%%%%%%@@@@%%%%%%@@@@@@@%%%*-:..-=*%%%%*+++++++==++*#%#+=+#%@@@@@@@@@@@@@@@@@@@@@@@@%+:::-=
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@%%%*--:.:=+*#@@@@@@@@@@@@@@@@%+=+%@@@@@@@@@@@@@@@@@@@@@@@@@@@*-::::
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+-=-.:-=+*#%@@@@@@@@@@@@@#++*%@@@@@@@@@@@@@@@@@@@@@@@@@@@@#-:..:
@@%%@@@@%%%%%%%%%%%%%%%%%%%%%%@@@%%#=--=-::===++#@@%%%###%%@%+=*%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%=:...
@@@@@@@@@%%%%%%%%%%%%%%%%%%%@@@@@%*---:-+=---====+##******##+=+%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*:...
%@@@@@@@@%%%%%%%%%%%%%%%%%%%%@@%#:.:-:.:-**+--====+#****++++=+%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#-:..
@@@@@@@@%%%%%%%%%%%%%%%%%%%%@%%+:...::::-=+**====-=##***++==*###%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%=:..
@@@@@@@@%%%%%%%%%%%%%%%%%%%%#+-.........-==+**+==-=*#****+=+*++++*#%%@@@@@@@@@@@@@@@@@@@@@@@@@@@+:..
@@@@@@@@%%%%%%%%%%%%%%%%%%*=--...........:-=++**==+*#***+++*++=----=*#%@@@@@@@@@@@@@@@@@@@@@@@@@#=..
@@@@@@@%%%%%%%%%%%%%%%#*=:..... .........::=+**+*##***++*+++==-:..::=#@@@@@@@@@@@@@@@@@@@@@@@@@#-.
@@@@@@@%%%%%%%%%%%%#+=:.:--:.... .........:::-=*#%##****#*++++==-:....:-*%@@@@@@@@@@@@@@@@@@@@@@%=.
@@@@@@%%%%%%%%%##+=-::=*****=:......:.....:::-==+*%%#*####*++++==--::....:-*%%@@@@@@@@@@@@@@@@@@@%+:
@@%%%%%%%%%##*=---:..:+%@@%%#*-...:::::::::=*###%*%%#######*+++==---:-=--::=*%@@@@@@@@@@@@@@@@@@@%*:
%%%%%%%%%%#*=::.....-=+#@@@@@%#+:.::-:::::-*#**#%@%#***#####+++===--+*+--:-+*%@@@@@@@@@@@@@@@@@@@@#-
%%%%%%%%#+:.....:-=+#%@@@@@@@@%%*::::::::-=*****##%%##%%%%%%#*+====#*+*+--*#*+#@@@@@@@@@@@@@@@@@@@%=
%%%%%#+-.....-==+**%@@@@@@@@@@@@@#=-::::-=+#*******#@@@@@@@@@@%##%%+===+*#@@%+==*%%%@@@@@@@@@@@@@@%+
%%#+-:.....:-=*#%##%@@@@@@@@@@@@@@@#+++**##+++++====+#@@@@@@@@@%*+==-===#@@@@#+-:-+#@@@@@@@@@@%%%%%#
*=:.....-=**###%@@%%@@@@@@@@@@@@@@@@@%*###*+=++++=====+#@@@@@@@#--------+%@@@%#*=---+%@@@@@@@%%%%%%%
...:-++*#%%%%%#++%%++#@@@@@@@@@@@@@@@@%#*+====+++++++++=+%@@@@@+-----=--=#@@@@@%#*+=--+%@@@@@%%%%%%%
::=*#%%@@@@%%%%%#**##*#%%%@@@@@@@@@@@@@@#++====+++===++++*%@@@@#=---===--*@@@@@@%%#**=:-+%@@@%%%%%%%
+##%@@@@@@@@@%%#*#%@%##*%%@@@@@@@@@@@@@@%#*******#**+++==+#@@@@@%+===+===+%@@@@@@@%%%#+-:=+#%%%%%%%%
#@@@@@@@@@@@@@@%%#%%%#*#%@@@@@@@@@@@@@@@@%#**######****++*%@@@@@@#++++++++#@@@@@@@@%@@%#++=-=#%%%%%%
%@@@@@@@@@@@@@@@@@%#*#%##%@@@@@@@@@@@@@@@@%#*****##*****+*%@@@@@@%*+++++++*%@@@@@@@@@@@%%#*=::+#%%%%
=#@@@@@@@@@@@@@@@@%#%%@@%##%@@@@@@@@@@@@@@@%#*+++*******+*%@@@@@@@#+++++++*%@@@@@@@@@@@@@%%#+-:-*%%%
-=#@@@@@@@@@@@@@@@@%###%#*%%%%%@@@@@@@@@@@@@@*====+++====*@@@@@@@@%*++++==*%@@@@@@@@@@@@@@@%%*+==#%%
--=*@@@@@@@@@@@@@@@@%%##%@%##%%%%%@@@@@@@@@@@%+=-==+=====*@@@@@@@@@*+=====+%@@@@@@@@@@@@@@@@%%#=:=#%
====*%@@@@@@@@@@@@@@%##%%@@%##%%%%%%%%@@@@@@@@%+--==+++++#@@@@@@@@@#=---==+%@@@@@@@@@@@@@@@@@@%+:-*%
++===+#@@@@@@@@@@@@@@@@%%###%%%%%%%%%%%@@@@@@@@#+===+++++#@@@@@@@@@#=---==+%@@@@@@@%@@@@@%%%%@%*--*#
++++===*%@@@@@@@@@@@@@@@%#%@@%%%%%%%%%@@@@@@@@@@#*++***++#@@@@@@@@@%+=====*%@@@@@@@%@@@@%%%%%%%*==+#
+++++==+*%@@@@@@@@@@@@%%##%@@@%#%@@@%%%@@@@@@@@@@#*****++%@@@@@@@@@%*+++++*%@@@@@@%%@@@@%%%%%%%#++*#
***++++=+*%@@@@@@@@@@@%%%%%###%%@@@@@@@@@@@@@@@@@@%%@@@%#%@@@@@@@@@@*+++++#%@@@@@@%%@%%@@@@@@@%#**##
*****+++++#@@@@@@@@@@@%%%%#*#%@%%%@@@@@@@@@@@@@@@@@@%#%@@@@@@@@@@@@@#+++++#%@@@@@@%%%%%@@@@@@@%###%%
******++++*%@@@@@@@@@@@@%%%%@@@@@%@@@@@@@@@@@@@@@@@%%%@@@@@@@@@@@@@@%+++++#%@@@@@%%%%%%%@@@@@@@%##%%
*/
//OVERARCHING LIBRARIES
#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <memory>
#include <type_traits>
//OPENGL LIBRARIES
#include<glad/glad.h>
#include<GLFW/glfw3.h>
//MANMADE LIBRARIES
#include "common.h"
#include "Engine.h"
#include "Window.h"
#include "Mouse.h"
#include "Keyboard.h"
#include "SoundSystem.h"
#include "ResourceManager.h"
#include "Net.h"
#include "Camera.h"
// Asks in the console whether to host, join or play offline (before the window opens,
// so the window isn't frozen while waiting for typing).
static void PromptNetworkMode() {
std::cout << "\n=== EIIFWHRN ===\n"
<< " 1) Host a LAN game\n"
<< " 2) Join a LAN game\n"
<< " 3) Offline\n"
<< "Choice [3]: ";
std::string choice;
std::getline(std::cin, choice);
Lan::Mode mode = Lan::Mode::Off;
std::string ip;
if (choice == "1") {
mode = Lan::Mode::Host;
std::cout << "\nHosting on UDP port 27015. Tell the other player to join one of these addresses: "
<< Lan::LocalAddresses() << "\n";
}
else if (choice == "2") {
mode = Lan::Mode::Client;
std::cout << "Host IP address [127.0.0.1]: ";
std::getline(std::cin, ip);
if (ip.empty()) ip = "127.0.0.1";
}
lan = new Lan();
if (mode != Lan::Mode::Off && !lan->Start(mode, ip)) {
std::cout << "[net] could not start networking, continuing offline\n";
}
}
// Mouse sensitivity as cm of mouse travel per 360 degree turn. Enter keeps the default.
static void PromptSensitivity() {
auto ask = [](const char* label, float& target) {
std::cout << label;
std::string line;
std::getline(std::cin, line);
try {
const float v = std::stof(line);
if (v > 0.0f) target = v;
}
catch (...) {} // empty / not a number: keep the default
};
std::cout << "\n=== MOUSE ===\n";
float cm = 0.0f, dpi = 800.0f;
ask("Sensitivity in cm per 360 degrees [default]: ", cm);
if (cm > 0.0f) ask("Mouse DPI [800]: ", dpi);
StartupCmPer360 = cm;
StartupMouseDpi = dpi;
}
int main() {
PromptNetworkMode();
PromptSensitivity();
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SAMPLES, 4);
//WINDOW INITIALIZATION
mouse = new Mouse();
keyboard = new Keyboard();
window = new Window(1920,1080,"EIIFWHRN");
soundsystem = new SoundSystem();
resourcemanager = new ResourceManager();
gladLoadGL();
Engine* enginee = new Engine();
engine->Initiate();
std::cout << "engine stopped\n";
delete window;
delete mouse;
delete keyboard;
delete engine;
delete lan;
glfwTerminate();
return 0;
}