+ added simulation.h and vector.h struct

- removed Vec2f
This commit is contained in:
End 2016-09-14 05:22:10 +02:00
parent cecfe55ba5
commit 63dc5ae6b7
6 changed files with 111 additions and 6 deletions

View file

@ -8,10 +8,15 @@ find_package(X11 REQUIRED)
set(GAME_SRC set(GAME_SRC
src/main.cpp src/main.cpp
src/opengl.cpp src/opengl.cpp
src/config.cpp
src/simulation.cpp
) )
set(GAME_HEADERS set(GAME_HEADERS
include/opengl.h include/opengl.h
include/vector.h
include/config.h
include/simulation.h
) )
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})

View file

@ -1,8 +1,5 @@
#pragma once #pragma once
#include <stdlib>
#include <stdio>
struct Config { struct Config {
int maxPlayers; int maxPlayers;
int numPlanets; int numPlanets;
@ -33,4 +30,4 @@ class ConfigParser{
private: private:
protected: protected:
public: public:
} };

View file

@ -0,0 +1,50 @@
#pragma once
#include <include/vector.h>
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;

51
KKK/game/include/vector.h Normal file
View file

@ -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;
}
};

View file

@ -31,7 +31,7 @@ public:
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
MainWindow window(500, 500); MainWindow window(500, 500);
window.setmaxfps(60); window.set_maxfps(60.0);
window.loop(); window.loop();
window.stop(); window.stop();
} }

View file

@ -0,0 +1,2 @@
#include <include/simulation.h>