Added the commandline argument to enable polygons
This commit is contained in:
parent
d2e95a7d93
commit
697d958bbf
17
main.cc
17
main.cc
@ -39,13 +39,15 @@ void check_collisions_with_index() {
|
|||||||
|
|
||||||
void (*check_collisions)() = check_collisions_simple;
|
void (*check_collisions)() = check_collisions_simple;
|
||||||
|
|
||||||
|
unsigned int polys = 0;
|
||||||
|
|
||||||
void update_state() {
|
void update_state() {
|
||||||
if (check_collisions)
|
if (check_collisions)
|
||||||
check_collisions();
|
check_collisions();
|
||||||
for (unsigned int i = 0; i < n_balls; ++i)
|
for (unsigned int i = 0; i < n_balls; ++i)
|
||||||
ball_update_state(balls + i);
|
ball_update_state(balls + i);
|
||||||
polygons_update_state();
|
|
||||||
spaceship_update_state();
|
spaceship_update_state();
|
||||||
|
polygons_update_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Graphics System
|
/* Graphics System
|
||||||
@ -55,8 +57,11 @@ void game_init() {
|
|||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
balls_init();
|
balls_init();
|
||||||
assert(c_index_init());
|
assert(c_index_init());
|
||||||
polygons_init_state();
|
|
||||||
// spaceship_init_state();
|
if (polys)
|
||||||
|
polygons_init_state();
|
||||||
|
else
|
||||||
|
spaceship_init_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_destroy() {
|
void game_destroy() {
|
||||||
@ -241,6 +246,7 @@ void print_usage(const char* progname) {
|
|||||||
"usage: %s [options...]\n"
|
"usage: %s [options...]\n"
|
||||||
"options:\n"
|
"options:\n"
|
||||||
"\t<width>x<height>\n"
|
"\t<width>x<height>\n"
|
||||||
|
"\tpolygons=<0 | 1> :: boolean\n"
|
||||||
"\tn=<number of balls>\n"
|
"\tn=<number of balls>\n"
|
||||||
"\tfconst=<x-force>,<y-force> :: constant force field\n"
|
"\tfconst=<x-force>,<y-force> :: constant force field\n"
|
||||||
"\tfnewt=<radius>,<g> :: radial, Newtonian force field\n"
|
"\tfnewt=<radius>,<g> :: radial, Newtonian force field\n"
|
||||||
@ -310,6 +316,11 @@ int main(int argc, const char* argv[]) {
|
|||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
if (sscanf(argv[i], "%dx%d", &w, &h) == 2)
|
if (sscanf(argv[i], "%dx%d", &w, &h) == 2)
|
||||||
continue;
|
continue;
|
||||||
|
if (sscanf(argv[i], "polygons=%u", &polys) == 1) {
|
||||||
|
if (polys)
|
||||||
|
n_balls = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (sscanf(argv[i], "n=%u", &n_balls) == 1)
|
if (sscanf(argv[i], "n=%u", &n_balls) == 1)
|
||||||
continue;
|
continue;
|
||||||
if (sscanf(argv[i], "fconst=%lf,%lf", &fa, &fb) == 2) {
|
if (sscanf(argv[i], "fconst=%lf,%lf", &fa, &fb) == 2) {
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
polygon* polygons = nullptr;
|
polygon* polygons = nullptr;
|
||||||
uint n_polygons = 11;
|
uint n_polygons = 0;
|
||||||
|
|
||||||
void polygons_init_state() {
|
void polygons_init_state() {
|
||||||
|
n_polygons = 11;
|
||||||
polygons = new polygon[n_polygons];
|
polygons = new polygon[n_polygons];
|
||||||
int wall_thickness = 50;
|
int wall_thickness = 50;
|
||||||
// north wall
|
// north wall
|
||||||
|
Loading…
Reference in New Issue
Block a user