From b45f1d015d0f64f3526e2e2ed39b7de2dae1724f Mon Sep 17 00:00:00 2001 From: Frank Villaro-Dixon Date: Thu, 1 Jan 2015 07:37:18 +0100 Subject: [PATCH] pulsations --- game.c | 7 ++++++- game.h | 3 ++- main.c | 11 ++++------- obs.c | 3 ++- polygons.c | 5 +++++ 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/game.c b/game.c index 06cacca..6ec8a5e 100644 --- a/game.c +++ b/game.c @@ -56,9 +56,13 @@ to_screen_coords(struct s_game *g, SDL_Point p) { q.x = p.x * cos(angle) - p.y * sin(angle); q.y = p.x * sin(angle) + p.y * cos(angle); +// q.x *= g->sexual_pulsation; +// q.y *= g->sexual_pulsation; + q.x += SCREEN_WIDTH/2; q.y += SCREEN_HEIGHT/2; + return q; } @@ -92,8 +96,8 @@ void void draw_game(struct s_game *g) { //{{{ draw_background(g); - draw_polygon(g); draw_obstacles(g); + draw_polygon(g); draw_cursor(g); } //}}} @@ -119,6 +123,7 @@ init_game(struct s_game *g) { //{{{ g->polygon_type = SHAPE_HEXAGON; g->cursor_angle = TO_DEG(90); g->general_rotation = 0; + g->sexual_pulsation = 1; g->color = 128; g->keys = SDL_GetKeyState(NULL); diff --git a/game.h b/game.h index af5c903..08e820e 100644 --- a/game.h +++ b/game.h @@ -15,7 +15,7 @@ #define SCREEN_DIAGONAL (sqrt(SCREEN_HEIGHT*SCREEN_HEIGHT + SCREEN_WIDTH*SCREEN_WIDTH)) -#define POLYGON_SIZE 30 +#define POLYGON_SIZE 50 #define SHAPE_SQUARE 4 #define SHAPE_PENTAGON 5 @@ -42,6 +42,7 @@ struct s_game { #define CURSOR_POS_MAX 255 int cursor_angle; //relative to the polygon center's referential int general_rotation; + float sexual_pulsation; int polygon_type; //Shape int color; int actual_speed; diff --git a/main.c b/main.c index 3851b37..4f5390e 100644 --- a/main.c +++ b/main.c @@ -6,6 +6,7 @@ #include #include +#include #include "SDL/SDL.h" #include "game.h" #include "sdl.h" @@ -49,15 +50,11 @@ start: ga.counter++; - if(rand()%30 == 0) { - rotation += rand()%20 - 10; - if(rotation > 15) - rotation = 15; - if(rotation < -13) - rotation = -13; - } ga.general_rotation += rotation; ga.general_rotation %= ANGLE_MAX; + + ga.sexual_pulsation = 0.3 * fabs(cos(ga.counter*M_PI/45)) + 1 + + 0.3 * fabs(sin(ga.counter*M_PI/90)); } return EXIT_SUCCESS; diff --git a/obs.c b/obs.c index 662effc..60733b8 100644 --- a/obs.c +++ b/obs.c @@ -74,8 +74,9 @@ update_obstacles(struct s_game *g) { //{{{ for(i = 0; i < g->num_obs; i++) { if(g->obs[i].used) { g->obs[i].distance -= g->obs[i].speed; + g->obs[i].thick = 3 * g->sexual_pulsation * SHAPE_THICK; - if(g->obs[i].distance <= POLYGON_SIZE) + if(g->obs[i].distance <= 0) g->obs[i].used = 0; } } diff --git a/polygons.c b/polygons.c index d30558f..64c0c4c 100644 --- a/polygons.c +++ b/polygons.c @@ -46,6 +46,11 @@ draw_polygon(struct s_game *g) { //{{{ void (*drawer)(struct s_game *, int faceno, int dist, int thick, int col); drawer = get_polygon_drawer(g); + for(faces = 0; faces < SHAPE_HEXAGON; faces++) { + drawer(g, faces, 0, POLYGON_SIZE, 0); + } + + for(faces = 0; faces < SHAPE_HEXAGON; faces++) { drawer(g, faces, POLYGON_SIZE, SHAPE_THICK-5, g->color); }