/* ** patterns.c - <+DESC+> ** ** 2014 - Frank Villaro-Dixon */ #include #include #include "game.h" #include "obs.h" void pattern_copyleft(struct s_game *g) { int times; int cleared_face = rand() % g->polygon_type; int max_dist = get_max_obs_dist(g); for(times = 0; times < g->polygon_type; times++) { if(times != cleared_face) { struct s_obstacle o; o = create_obstacle(SHAPE_THICK, times, 1, max_dist + K_CLEARANCE); add_obstacle(g, o); } } } void pattern_schenille(struct s_game *g) { int times; int cleared_face = rand() % g->polygon_type; int max_dist = get_max_obs_dist(g); int dir = 1 - 2 * (rand()%2); int leng = rand()%7 + 10; for(times = 0; times < leng; times++) { struct s_obstacle o; o = create_obstacle(SHAPE_THICK, cleared_face, 1, max_dist + K_CLEARANCE + times*SHAPE_THICK); add_obstacle(g, o); cleared_face += dir; CLEVER_MODULO(cleared_face, g->polygon_type); } } void add_pattern(struct s_game *g) { int n_patterns = 2; void (*patterns[])(struct s_game *g) = {pattern_copyleft, pattern_schenille}; int choosen_pattern = rand() % n_patterns; patterns[choosen_pattern](g); }