-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
41 lines (28 loc) · 785 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//#define DEBUG
#include <iostream>
#include <chrono>
#include <thread>
#include "state.h"
#include "graphics.h"
int main(int argc, char** argv) {
if(argc < 3){
std::cout << "Usage: " << argv[0] << " board_height board_width [frames per second][number of frames]" << std::endl;
return 1;
}
int height = std::stoi(argv[1]);
int width = std::stoi(argv[2]);
double speed = 60;
int frames = int(1e6);
if(argc > 3) speed = std::stoi(argv[3]);
if(argc > 4) frames = std::stoi(argv[4]);
graphics window(height,width);
state simulation;
simulation.init(height,width);
window.draw(simulation);
while(frames --> 0){
simulation.step();
if(!window.draw(simulation)) break;
std::this_thread::sleep_for(std::chrono::microseconds(int(1e6/speed)));
}
return 0;
}