You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.5 KiB

#ifndef __GAMEOFLIFE_H
#define __GAMEOFLIFE_H
#include <string>
#include <fstream>
#include <SDL_opengl.h>
#include <cstdlib>
#include <ctime>
#include <SDL.h>
#include "emath.h"
#include "punkt2d.h"
typedef enum { dead=0, alife, dies, born } State;
class GameOfLife {
private:
State **feld;
int x, y;
bool torus;
bool fullcelluse;
unsigned long generation;
GLUquadricObj *quad;
// Brett
float thickness;
float cellwidth;
// Cylinder
float radius;
float height;
int parts;
float *sinval;
float *cosval;
//render
bool view3d;
float sectobuild;
float b_secdone;
float secpertick;
float t_secdone;
// Edit
segl::Punkt2D setpos;
bool editmode;
void init();
void allocate();
void cleanup();
void renderBrett();
void renderStein(State s);
void translateTo(int _x, int _y);
void lockStates();
public:
GameOfLife(int _x, int _y);
GameOfLife(int _x, int _y, int r_life, int r_dead);
GameOfLife(std::string file);
~GameOfLife();
void set3D(bool on);
bool load(std::string file);
bool save(std::string file);
void fillRandom(int _x, int _y, int r_life, int r_dead);
// void toggle(int _x, int _y);
void setEditMode(bool e);
void move(int up, int right);
void toggle();
float getTickSec();
float getBuildSec();
void setTickSec(float s);
void setBuildSec(float s);
void setTorus(bool t);
unsigned long getGeneration();
// const bool** getFeld();
void tick();
void render(float sec);
void clear();
};
#endif