diff --git a/KKK/game/CMakeLists.txt b/KKK/game/CMakeLists.txt index 562fa03..b6b0151 100644 --- a/KKK/game/CMakeLists.txt +++ b/KKK/game/CMakeLists.txt @@ -8,10 +8,15 @@ find_package(X11 REQUIRED) set(GAME_SRC src/main.cpp src/opengl.cpp + src/config.cpp + src/simulation.cpp ) set(GAME_HEADERS - include/opengl.h + include/opengl.h + include/vector.h + include/config.h + include/simulation.h ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/KKK/game/include/config.h b/KKK/game/include/config.h index e1ea4ba..aacc673 100644 --- a/KKK/game/include/config.h +++ b/KKK/game/include/config.h @@ -1,8 +1,5 @@ #pragma once -#include -#include - struct Config { int maxPlayers; int numPlanets; @@ -33,4 +30,4 @@ class ConfigParser{ private: protected: public: -} +}; diff --git a/KKK/game/include/simulation.h b/KKK/game/include/simulation.h new file mode 100644 index 0000000..beeb928 --- /dev/null +++ b/KKK/game/include/simulation.h @@ -0,0 +1,50 @@ +#pragma once + +#include + +typedef struct +{ + Vec2d position; + Vec2d speed; + int live; + int leftSource; + int stale; +} SimMissile; + +typedef struct +{ + Vec2d* dot; + SimMissile missile; + int length; + int player; + double angle; + double velocity; +} SimShot; + +typedef struct +{ + SimShot* shot; + int currentShot; + Vec2d position; + double angle; + double velocity; + double energy; + double oldVelocity; + int watch; + int deaths; + int kills; + int shots; + int active; + int valid; + int didShoot; + int timeout; + int timeoutcnt; + char name[16]; +} SimPlayer; + +typedef struct +{ + Vec2d position; + double radius; + double mass; +} SimPlanet; diff --git a/KKK/game/include/vector.h b/KKK/game/include/vector.h new file mode 100644 index 0000000..8bbe558 --- /dev/null +++ b/KKK/game/include/vector.h @@ -0,0 +1,51 @@ +#pragma once + +struct Vec2d +{ + double x; + double y; + + Vec2d & operator+=(const Vec2d& rhs) { + x+=rhs.x; + y+=rhs.y; + return *this; + } + Vec2d & operator-=(const Vec2d& rhs) { + x-=rhs.x; + y-=rhs.y; + return *this; + } + Vec2d & operator*=(const double& rhs) { + x*=rhs; + y*=rhs; + return *this; + } + Vec2d & operator/=(const double& rhs) { + x/=rhs; + y/=rhs; + return *this; + } + const Vec2d operator+(const Vec2d& rhs) const { + Vec2d result = *this; + result += rhs; + return result; + } + const Vec2d operator-(const Vec2d& rhs) const { + Vec2d result = *this; + result -= rhs; + return result; + } + const double operator*(const Vec2d& rhs) const { + return (this->x * rhs.x) + (this->y * rhs.y); + } + const Vec2d operator*(const double& rhs) const { + Vec2d result = *this; + result *= rhs; + return result; + } + const Vec2d operator/(const double& rhs) const { + Vec2d result = *this; + result /= rhs; + return result; + } +}; diff --git a/KKK/game/src/main.cpp b/KKK/game/src/main.cpp index 495c739..132a2ba 100644 --- a/KKK/game/src/main.cpp +++ b/KKK/game/src/main.cpp @@ -31,7 +31,7 @@ public: int main(int argc, const char *argv[]) { MainWindow window(500, 500); - window.setmaxfps(60); + window.set_maxfps(60.0); window.loop(); window.stop(); } diff --git a/KKK/game/src/simulation.cpp b/KKK/game/src/simulation.cpp new file mode 100644 index 0000000..a0b9b44 --- /dev/null +++ b/KKK/game/src/simulation.cpp @@ -0,0 +1,2 @@ +#include +