beats: shapes and color

This commit is contained in:
Frank Villaro-Dixon 2015-01-04 10:32:30 +01:00
parent ec954823b5
commit f2cef6b0f5
3 changed files with 33 additions and 7 deletions

View file

@ -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;

View file

@ -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 */

View file

@ -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;