+ added readme

* fixed timebased movement & maxfps
This commit is contained in:
End 2016-09-14 04:14:39 +02:00
parent 39af185188
commit cecfe55ba5
6 changed files with 109 additions and 10 deletions

36
KKK/game/include/config.h Normal file
View file

@ -0,0 +1,36 @@
#pragma once
#include <stdlib>
#include <stdio>
struct Config {
int maxPlayers;
int numPlanets;
int maxSegments;
int segmentSteps;
int numShots;
int fastmode;
int fullscreen;
int timeout;
int margintop;
int marginleft;
int marginright;
int marginbottom;
double playerSize;
int energy;
int realtime;
int debug;
double battlefieldW;
double battlefieldH;
int throttle;
char* ip;
char* message;
int pot;
int area;
};
class ConfigParser{
private:
protected:
public:
}

View file

@ -11,6 +11,7 @@ namespace endofthejedi {
class GLWindow {
private:
//X-related stuff
Display* m_display;
Window m_rootwnd;
GLint m_attributes[23] =
@ -35,25 +36,44 @@ class GLWindow {
GLXContext m_glcontext;
XWindowAttributes m_gwa;
Atom m_atomWmDeleteWindow;
//End of X related stuff
unsigned int m_width;
unsigned int m_height;
//mainloop condition
bool m_running = false;
double m_fps;
//if maxfps = 0 there's no fps limit
double m_maxfps;
void handleevents();
protected:
virtual void handle(XEvent event);
//ancestors shall override these methods
virtual void init();
//called by mainloop periodically
//time shall be used for timebased movement
virtual void render(double time);
//called by handle on window resize
virtual void resize();
//the ancestor should call the handle function in this class, too,
//as it handles the close calls & resizing
virtual void handle(XEvent event);
public:
//initializes the X Window & creates an OpenGL context
GLWindow(unsigned int width, unsigned int height);
~GLWindow();
//mainloop does event handling & calls render/swap
void loop();
void stop();
void swap();
//stops the mainloop by setting m_running false
void stop();
//getters
unsigned int getheight() const {
return m_height;
}
@ -61,6 +81,23 @@ class GLWindow {
unsigned int getwidth() const {
return m_width;
}
double get_maxfps() const {
return m_maxfps;
}
double get_fps() const {
return m_fps;
}
bool get_running() const {
return m_running;
}
//setters
void set_maxfps(const double maxfps) {
m_maxfps = maxfps;
}
};
}