Merge branch 'master' of vi-di.fr:rotagon
Conflicts: src/game.h
This commit is contained in:
commit
8462f62073
4 changed files with 22 additions and 29 deletions
23
src/game.c
23
src/game.c
|
@ -77,29 +77,26 @@ get_circle_vertice(int angle, int dist) { //{{{
|
|||
p.x = cos((double)angle*2*M_PI/ANGLE_MAX) * dist;
|
||||
p.y = sin((double)angle*2*M_PI/ANGLE_MAX) * dist;
|
||||
|
||||
OFFSET_POINT(p);
|
||||
OFFSET_POINT_2SCREEN(p);
|
||||
|
||||
return p;
|
||||
} //}}}
|
||||
|
||||
SDL_Point
|
||||
to_screen_coords(struct s_game *g, SDL_Point p) { //{{{
|
||||
SDL_Point q;
|
||||
SDL_Point pp;
|
||||
|
||||
|
||||
p.x -= SCREEN_WIDTH/2;
|
||||
p.y -= SCREEN_HEIGHT/2;
|
||||
float angle = TO_RAD(g->general_rotation);
|
||||
|
||||
q.x = p.x * cos(angle) - p.y * sin(angle);
|
||||
q.y = p.x * sin(angle) + p.y * cos(angle);
|
||||
OFFSET_POINT_2IT(p);
|
||||
pp.x = p.x * cos(angle) - p.y * sin(angle);
|
||||
pp.y = p.x * sin(angle) + p.y * cos(angle);
|
||||
// pp.x *= g->sexual_pulsation;
|
||||
// pp.y *= g->sexual_pulsation;
|
||||
OFFSET_POINT_2SCREEN(pp);
|
||||
|
||||
// q.x *= g->sexual_pulsation;
|
||||
// q.y *= g->sexual_pulsation;
|
||||
|
||||
q.x += SCREEN_WIDTH/2;
|
||||
q.y += SCREEN_HEIGHT/2;
|
||||
|
||||
return q;
|
||||
return pp;
|
||||
}//}}}
|
||||
|
||||
void
|
||||
|
|
12
src/game.h
12
src/game.h
|
@ -17,12 +17,10 @@
|
|||
#define CLEVER_MODULO(n, mod) do { while(n < 0) { n += mod; };;;; n %= mod; } while(0);
|
||||
|
||||
|
||||
#define DEC_COLOR 0x00020202
|
||||
#define DIVIDE_COLOR(color, times) (((color) & 0x00ff0000 / (times)) | ((color) & 0x0000ff00 / (times)) | ((color) & 0x000000ff / (times)))
|
||||
|
||||
////POLYGON
|
||||
#define POLYGON_SIZE 50
|
||||
#define POLYGON_THICK 15
|
||||
|
||||
//SHAPES
|
||||
#define SHAPE_TRIANGLE 3
|
||||
#define SHAPE_SQUARE 4
|
||||
|
@ -30,14 +28,17 @@
|
|||
#define SHAPE_HEXAGON 6
|
||||
|
||||
#define SHAPE_THICK 60
|
||||
|
||||
|
||||
#define DFT_OBS_SPEED (SHAPE_THICK / 15)
|
||||
|
||||
#define CURSOR_DIST (POLYGON_SIZE + POLYGON_THICK + 20)
|
||||
#define CURSOR_DEG_FRAME (24 / g->polygon_type)
|
||||
#define ANGLE_MAX 3600
|
||||
|
||||
#define OFFSET_POINT(p) {p.x += SCREEN_WIDTH/2; p.y += SCREEN_HEIGHT/2;}
|
||||
#define MAX(a, b) (a < b) ? (b) : (a)
|
||||
#define OFFSET_POINT_2IT(p) {p.x -= SCREEN_WIDTH/2; p.y -= SCREEN_HEIGHT/2;}
|
||||
#define OFFSET_POINT_2SCREEN(p) {p.x += SCREEN_WIDTH/2; p.y += SCREEN_HEIGHT/2;}
|
||||
#define MAX(a, b) (((a) > (b) ? (a) : (b)))
|
||||
#define MIN(a, b) (a < b) ? (a) : (b)
|
||||
|
||||
#define TO_DEG(x) (x*ANGLE_MAX/360)
|
||||
|
@ -54,7 +55,6 @@ struct s_obstacle {
|
|||
};
|
||||
|
||||
struct s_game {
|
||||
#define CURSOR_POS_MAX 255
|
||||
int cursor_angle; //relative to the polygon center's referential
|
||||
int general_rotation;
|
||||
float sexual_pulsation;
|
||||
|
|
10
src/main.c
10
src/main.c
|
@ -30,18 +30,14 @@ start:
|
|||
|
||||
|
||||
while(1) {
|
||||
//clear the screen
|
||||
SDL_FillRect(ga.screen, NULL, 0);
|
||||
|
||||
if(did_have_beat(&ga)) {
|
||||
ga.sexual_pulsation = 60;
|
||||
puts("Pulse");
|
||||
}
|
||||
|
||||
/*
|
||||
if(!(ga.counter % 28)) {
|
||||
add_random_obstacle(&ga);
|
||||
}
|
||||
*/
|
||||
|
||||
if(get_max_obs_dist(&ga) < SCREEN_DIAGONAL)
|
||||
add_pattern(&ga);
|
||||
|
||||
|
@ -50,7 +46,7 @@ start:
|
|||
SDL_Flip(ga.screen);
|
||||
|
||||
if(check_collisions(&ga)) {
|
||||
puts("PERDU, connard !");
|
||||
puts("PERDU");
|
||||
SDL_Delay(2000);
|
||||
goto start;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ get_hexagon_vertice(int faceno, int dist) { //{{{
|
|||
p1.x = dist * cos((M_PI/3)*faceno);
|
||||
p1.y = dist * sin((M_PI/3)*faceno);
|
||||
|
||||
OFFSET_POINT(p1);
|
||||
OFFSET_POINT_2SCREEN(p1);
|
||||
|
||||
return p1;
|
||||
} //}}}
|
||||
|
@ -34,7 +34,7 @@ get_square_vertice(int faceno, int dist) { //{{{
|
|||
p1.x = dist * cos((M_PI/2)*faceno);
|
||||
p1.y = dist * sin((M_PI/2)*faceno);
|
||||
|
||||
OFFSET_POINT(p1);
|
||||
OFFSET_POINT_2SCREEN(p1);
|
||||
|
||||
return p1;
|
||||
} //}}}
|
||||
|
@ -45,7 +45,7 @@ get_triangle_vertice(int faceno, int dist) { //{{{
|
|||
p1.x = dist * cos((2*M_PI/3)*faceno);
|
||||
p1.y = dist * sin((2*M_PI/3)*faceno);
|
||||
|
||||
OFFSET_POINT(p1);
|
||||
OFFSET_POINT_2SCREEN(p1);
|
||||
|
||||
return p1;
|
||||
} //}}}
|
||||
|
|
Loading…
Reference in a new issue