From f2cef6b0f5edecffd38e14405c7d71bcd3c6f366 Mon Sep 17 00:00:00 2001 From: Frank Villaro-Dixon Date: Sun, 4 Jan 2015 10:32:30 +0100 Subject: [PATCH] beats: shapes and color --- src/game.c | 13 ++++++++++++- src/game.h | 3 +++ src/main.c | 24 ++++++++++++++++++------ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/game.c b/src/game.c index 583a492..70a5f8a 100644 --- a/src/game.c +++ b/src/game.c @@ -34,6 +34,17 @@ divide_color(int color, int divider) { return col.col; } +void +init_random_color(struct s_game *g) { + union color col; + col.col = 0; + col.rgb.col[0] = rand()%2 ? 0 : 255; + col.rgb.col[1] = rand()%2 ? 0 : 255; + col.rgb.col[2] = rand()%2 ? 0 : 255; + + g->color = col.col; +} + void change_game_color(struct s_game *g) { static int from_canal = 0; @@ -141,7 +152,7 @@ get_keys(struct s_game *g) { //{{{ } //}}} void init_game(struct s_game *g) { //{{{ - g->polygon_type = SHAPE_SQUARE; + g->polygon_type = SHAPE_HEXAGON; g->cursor_angle = TO_DEG(90); g->general_rotation = 0; g->sexual_pulsation = 1; diff --git a/src/game.h b/src/game.h index 9f1512c..11bea63 100644 --- a/src/game.h +++ b/src/game.h @@ -116,6 +116,9 @@ get_keys(struct s_game *g); void change_game_color(struct s_game *g); +void +init_random_color(struct s_game *g); + #endif /* ndef GAME_H */ diff --git a/src/main.c b/src/main.c index aab024c..c8e956a 100644 --- a/src/main.c +++ b/src/main.c @@ -28,7 +28,7 @@ main() start: init_game(&ga); music_loadnplay(&ga); - + int rotation_adder = 0; struct s_obstacle a = create_obstacle(SHAPE_THICK, 2, 1, -1); add_obstacle(&ga, a); @@ -38,7 +38,21 @@ start: SDL_FillRect(ga.screen, NULL, 0); if(did_have_beat(&ga)) { - ga.sexual_pulsation = 60; + ga.sexual_pulsation = 40; + + if(!(rand()%10)) { + change_game_color(&ga); + rotation_adder = rand()%3; + } + if(!(rand()%50)) { + switch(ga.polygon_type) { + case SHAPE_SQUARE: + ga.polygon_type = SHAPE_HEXAGON; + break; + case SHAPE_HEXAGON: + ga.polygon_type = SHAPE_SQUARE; + } + } puts("Pulse"); } @@ -63,15 +77,13 @@ start: ga.counter++; - ga.general_rotation = ga.counter*3; -// ga.sexual_pulsation = 0.3 * fabs(cos(ga.counter*M_PI/45)) + 1 + -// 0.3 * fabs(sin(ga.counter*M_PI/90)); + ga.general_rotation += (3*rotation_adder) + 3; if(!(ga.counter % 10)) change_game_color(&ga); - ga.sexual_pulsation -= 2; + ga.sexual_pulsation--; if(ga.sexual_pulsation < 0) ga.sexual_pulsation = 0;