+ added simulation.h and vector.h struct
- removed Vec2f
This commit is contained in:
parent
cecfe55ba5
commit
63dc5ae6b7
6 changed files with 111 additions and 6 deletions
|
@ -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/vector.h
|
||||
include/config.h
|
||||
include/simulation.h
|
||||
)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdlib>
|
||||
#include <stdio>
|
||||
|
||||
struct Config {
|
||||
int maxPlayers;
|
||||
int numPlanets;
|
||||
|
@ -33,4 +30,4 @@ class ConfigParser{
|
|||
private:
|
||||
protected:
|
||||
public:
|
||||
}
|
||||
};
|
||||
|
|
50
KKK/game/include/simulation.h
Normal file
50
KKK/game/include/simulation.h
Normal 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
51
KKK/game/include/vector.h
Normal 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;
|
||||
}
|
||||
};
|
|
@ -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();
|
||||
}
|
||||
|
|
2
KKK/game/src/simulation.cpp
Normal file
2
KKK/game/src/simulation.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include <include/simulation.h>
|
||||
|
Loading…
Reference in a new issue