pulsations
This commit is contained in:
parent
2bb09b07f2
commit
b45f1d015d
5 changed files with 19 additions and 10 deletions
7
game.c
7
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);
|
||||
|
||||
|
|
3
game.h
3
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;
|
||||
|
|
11
main.c
11
main.c
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#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;
|
||||
|
|
3
obs.c
3
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue