60 lines
1.3 KiB
C++
60 lines
1.3 KiB
C++
#ifndef Game_h_
|
|
#define Game_h_
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <list>
|
|
#include <sstream>
|
|
|
|
#define SDL_MAIN_HANDLED
|
|
#include <SDL.h>
|
|
#include <SDL_mixer.h>
|
|
#include <SDL_ttf.h>
|
|
|
|
#define GL_GLEXT_PROTOTYPES
|
|
#define GLEW_STATIC
|
|
#include "glew/glew.h"
|
|
|
|
#include "Node.hpp"
|
|
#include "Configuration.hpp"
|
|
|
|
struct Game : Node
|
|
{
|
|
|
|
Game(const Game&) = delete;
|
|
Game& operator=(const Game&) = delete;
|
|
Game(Game&&) = delete;
|
|
Game& operator=(Game&&) = delete;
|
|
|
|
SDL_Window *window;
|
|
SDL_Renderer *renderer = NULL;
|
|
SDL_GLContext glcontext = NULL;
|
|
int sw = 640, sh = 480, framerate = 60, frame_time_overflow = 0,
|
|
last_frame_timestamp, frame_count_timestamp, ticks,
|
|
last_frame_length;
|
|
float frame_length = 1000.0 / framerate;
|
|
bool done = false, show_framerate = false, is_gl_context = true;
|
|
Configuration configuration;
|
|
|
|
Game();
|
|
void print_error(std::string);
|
|
void print_sdl_error(std::string);
|
|
void print_gl_attributes();
|
|
void load_sdl_context();
|
|
void load_gl_context();
|
|
void run();
|
|
void flag_to_end();
|
|
virtual void update() = 0;
|
|
void set_framerate(int);
|
|
void quit();
|
|
|
|
template<typename T>
|
|
float get_weighted_amount(T amount)
|
|
{
|
|
return (last_frame_length / (1000.0 / 60)) * amount;
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|