patterns and shape
This commit is contained in:
parent
113192f897
commit
5759435515
7 changed files with 237 additions and 243 deletions
4
game.c
4
game.c
|
@ -126,6 +126,10 @@ void
|
|||
switch(g->polygon_type) {
|
||||
case SHAPE_HEXAGON:
|
||||
return draw_hexagon_side;
|
||||
case SHAPE_SQUARE:
|
||||
return draw_square_side;
|
||||
case SHAPE_TRIANGLE:
|
||||
return draw_triangle_side;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
|
3
game.h
3
game.h
|
@ -24,6 +24,7 @@
|
|||
#define POLYGON_SIZE 50
|
||||
#define POLYGON_THICK 15
|
||||
//SHAPES
|
||||
#define SHAPE_TRIANGLE 3
|
||||
#define SHAPE_SQUARE 4
|
||||
#define SHAPE_PENTAGON 5
|
||||
#define SHAPE_HEXAGON 6
|
||||
|
@ -32,7 +33,7 @@
|
|||
#define DFT_OBS_SPEED (SHAPE_THICK / 15)
|
||||
|
||||
#define CURSOR_DIST (POLYGON_SIZE + POLYGON_THICK + 20)
|
||||
#define CURSOR_DEG_FRAME 4
|
||||
#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;}
|
||||
|
|
195
mus.beats
195
mus.beats
|
@ -1,120 +1,75 @@
|
|||
3.478971504
|
||||
3.908721077
|
||||
4.403935869
|
||||
4.802079513
|
||||
5.231328869
|
||||
5.726398469
|
||||
6.292892650
|
||||
6.651166277
|
||||
7.281341085
|
||||
7.838964401
|
||||
8.174127654
|
||||
8.845021297
|
||||
9.250352215
|
||||
9.979038255
|
||||
10.263189375
|
||||
10.717596702
|
||||
11.516638157
|
||||
11.906187719
|
||||
12.320373739
|
||||
12.486463105
|
||||
13.092972177
|
||||
13.458849538
|
||||
13.833720025
|
||||
14.536104822
|
||||
14.741685451
|
||||
14.955862462
|
||||
15.114124260
|
||||
15.304128177
|
||||
15.485349969
|
||||
16.164889760
|
||||
16.370940952
|
||||
16.536728410
|
||||
16.703110419
|
||||
16.868993919
|
||||
17.051304610
|
||||
17.746002574
|
||||
17.903978254
|
||||
18.069505746
|
||||
18.227990623
|
||||
18.385867342
|
||||
18.559098016
|
||||
18.693787809
|
||||
19.252436005
|
||||
19.409790749
|
||||
19.576902863
|
||||
19.742827603
|
||||
19.908818622
|
||||
20.074708474
|
||||
20.770184100
|
||||
20.927291428
|
||||
21.109685436
|
||||
21.299194030
|
||||
21.465285948
|
||||
21.655520865
|
||||
22.302186210
|
||||
22.468318590
|
||||
22.649564228
|
||||
22.816768086
|
||||
22.990643496
|
||||
23.188521385
|
||||
23.843267128
|
||||
24.001009355
|
||||
24.175080651
|
||||
24.341629235
|
||||
24.507805410
|
||||
24.729735231
|
||||
25.376552678
|
||||
25.526366629
|
||||
25.716080665
|
||||
25.874346371
|
||||
26.048735281
|
||||
26.230810459
|
||||
26.900772354
|
||||
27.067036963
|
||||
27.257092015
|
||||
27.430609985
|
||||
27.620737425
|
||||
27.827840102
|
||||
28.458482964
|
||||
28.616059764
|
||||
28.805939082
|
||||
28.980286985
|
||||
29.146212536
|
||||
29.328634725
|
||||
29.959476487
|
||||
30.132907390
|
||||
30.315087769
|
||||
30.488907413
|
||||
30.662347602
|
||||
30.845392986
|
||||
31.539602881
|
||||
31.705751894
|
||||
31.872098030
|
||||
32.053844272
|
||||
32.220097929
|
||||
32.402418987
|
||||
33.065130109
|
||||
33.230875059
|
||||
33.412743977
|
||||
33.586377752
|
||||
33.769063976
|
||||
33.942760398
|
||||
34.581584314
|
||||
34.738743523
|
||||
34.903622313
|
||||
35.077701542
|
||||
35.275951959
|
||||
35.459199422
|
||||
36.130339242
|
||||
36.280349194
|
||||
36.446580092
|
||||
36.612444517
|
||||
36.795051048
|
||||
37.017111426
|
||||
37.647930747
|
||||
37.829569193
|
||||
38.003692143
|
||||
38.202124950
|
||||
38.375920708
|
||||
38.573240177
|
||||
2.847254552
|
||||
2.997123886
|
||||
3.187358367
|
||||
3.329112981
|
||||
3.903859124
|
||||
4.093101074
|
||||
4.628480381
|
||||
4.810299832
|
||||
5.000607697
|
||||
5.190262526
|
||||
5.724933872
|
||||
5.882498013
|
||||
6.145166568
|
||||
6.358887131
|
||||
6.557398015
|
||||
6.739249437
|
||||
7.329791416
|
||||
7.923106506
|
||||
8.352454416
|
||||
8.922743422
|
||||
9.095985371
|
||||
10.047007003
|
||||
10.219828993
|
||||
10.581944582
|
||||
11.564514422
|
||||
11.746278661
|
||||
11.928596176
|
||||
12.118479017
|
||||
12.308819651
|
||||
13.194737393
|
||||
13.697964142
|
||||
14.656913675
|
||||
14.838240846
|
||||
15.020543878
|
||||
15.202888304
|
||||
15.400701241
|
||||
16.205802392
|
||||
16.372948980
|
||||
16.555745773
|
||||
16.729538514
|
||||
17.767830749
|
||||
17.942386845
|
||||
18.108622017
|
||||
18.290055586
|
||||
18.456553392
|
||||
19.239673241
|
||||
19.795658812
|
||||
20.854475954
|
||||
21.052255889
|
||||
21.521443159
|
||||
21.670031277
|
||||
22.489120616
|
||||
22.653419373
|
||||
23.088754125
|
||||
23.254390492
|
||||
23.824465858
|
||||
23.982048166
|
||||
24.504870599
|
||||
24.656008352
|
||||
25.407961235
|
||||
25.797650266
|
||||
26.313551326
|
||||
26.520676395
|
||||
26.686349445
|
||||
26.868799111
|
||||
27.042173361
|
||||
27.446639331
|
||||
28.100783371
|
||||
28.249282315
|
||||
28.792045848
|
||||
28.998001125
|
||||
29.170862984
|
||||
29.354634960
|
||||
29.560513659
|
||||
29.774344974
|
||||
|
|
195
mus_beats.h
195
mus_beats.h
|
@ -1,122 +1,77 @@
|
|||
float mus_beats[] = {
|
||||
3.478971504,
|
||||
3.908721077,
|
||||
4.403935869,
|
||||
4.802079513,
|
||||
5.231328869,
|
||||
5.726398469,
|
||||
6.292892650,
|
||||
6.651166277,
|
||||
7.281341085,
|
||||
7.838964401,
|
||||
8.174127654,
|
||||
8.845021297,
|
||||
9.250352215,
|
||||
9.979038255,
|
||||
10.263189375,
|
||||
10.717596702,
|
||||
11.516638157,
|
||||
11.906187719,
|
||||
12.320373739,
|
||||
12.486463105,
|
||||
13.092972177,
|
||||
13.458849538,
|
||||
13.833720025,
|
||||
14.536104822,
|
||||
14.741685451,
|
||||
14.955862462,
|
||||
15.114124260,
|
||||
15.304128177,
|
||||
15.485349969,
|
||||
16.164889760,
|
||||
16.370940952,
|
||||
16.536728410,
|
||||
16.703110419,
|
||||
16.868993919,
|
||||
17.051304610,
|
||||
17.746002574,
|
||||
17.903978254,
|
||||
18.069505746,
|
||||
18.227990623,
|
||||
18.385867342,
|
||||
18.559098016,
|
||||
18.693787809,
|
||||
19.252436005,
|
||||
19.409790749,
|
||||
19.576902863,
|
||||
19.742827603,
|
||||
19.908818622,
|
||||
20.074708474,
|
||||
20.770184100,
|
||||
20.927291428,
|
||||
21.109685436,
|
||||
21.299194030,
|
||||
21.465285948,
|
||||
21.655520865,
|
||||
22.302186210,
|
||||
22.468318590,
|
||||
22.649564228,
|
||||
22.816768086,
|
||||
22.990643496,
|
||||
23.188521385,
|
||||
23.843267128,
|
||||
24.001009355,
|
||||
24.175080651,
|
||||
24.341629235,
|
||||
24.507805410,
|
||||
24.729735231,
|
||||
25.376552678,
|
||||
25.526366629,
|
||||
25.716080665,
|
||||
25.874346371,
|
||||
26.048735281,
|
||||
26.230810459,
|
||||
26.900772354,
|
||||
27.067036963,
|
||||
27.257092015,
|
||||
27.430609985,
|
||||
27.620737425,
|
||||
27.827840102,
|
||||
28.458482964,
|
||||
28.616059764,
|
||||
28.805939082,
|
||||
28.980286985,
|
||||
29.146212536,
|
||||
29.328634725,
|
||||
29.959476487,
|
||||
30.132907390,
|
||||
30.315087769,
|
||||
30.488907413,
|
||||
30.662347602,
|
||||
30.845392986,
|
||||
31.539602881,
|
||||
31.705751894,
|
||||
31.872098030,
|
||||
32.053844272,
|
||||
32.220097929,
|
||||
32.402418987,
|
||||
33.065130109,
|
||||
33.230875059,
|
||||
33.412743977,
|
||||
33.586377752,
|
||||
33.769063976,
|
||||
33.942760398,
|
||||
34.581584314,
|
||||
34.738743523,
|
||||
34.903622313,
|
||||
35.077701542,
|
||||
35.275951959,
|
||||
35.459199422,
|
||||
36.130339242,
|
||||
36.280349194,
|
||||
36.446580092,
|
||||
36.612444517,
|
||||
36.795051048,
|
||||
37.017111426,
|
||||
37.647930747,
|
||||
37.829569193,
|
||||
38.003692143,
|
||||
38.202124950,
|
||||
38.375920708,
|
||||
38.573240177,
|
||||
2.847254552,
|
||||
2.997123886,
|
||||
3.187358367,
|
||||
3.329112981,
|
||||
3.903859124,
|
||||
4.093101074,
|
||||
4.628480381,
|
||||
4.810299832,
|
||||
5.000607697,
|
||||
5.190262526,
|
||||
5.724933872,
|
||||
5.882498013,
|
||||
6.145166568,
|
||||
6.358887131,
|
||||
6.557398015,
|
||||
6.739249437,
|
||||
7.329791416,
|
||||
7.923106506,
|
||||
8.352454416,
|
||||
8.922743422,
|
||||
9.095985371,
|
||||
10.047007003,
|
||||
10.219828993,
|
||||
10.581944582,
|
||||
11.564514422,
|
||||
11.746278661,
|
||||
11.928596176,
|
||||
12.118479017,
|
||||
12.308819651,
|
||||
13.194737393,
|
||||
13.697964142,
|
||||
14.656913675,
|
||||
14.838240846,
|
||||
15.020543878,
|
||||
15.202888304,
|
||||
15.400701241,
|
||||
16.205802392,
|
||||
16.372948980,
|
||||
16.555745773,
|
||||
16.729538514,
|
||||
17.767830749,
|
||||
17.942386845,
|
||||
18.108622017,
|
||||
18.290055586,
|
||||
18.456553392,
|
||||
19.239673241,
|
||||
19.795658812,
|
||||
20.854475954,
|
||||
21.052255889,
|
||||
21.521443159,
|
||||
21.670031277,
|
||||
22.489120616,
|
||||
22.653419373,
|
||||
23.088754125,
|
||||
23.254390492,
|
||||
23.824465858,
|
||||
23.982048166,
|
||||
24.504870599,
|
||||
24.656008352,
|
||||
25.407961235,
|
||||
25.797650266,
|
||||
26.313551326,
|
||||
26.520676395,
|
||||
26.686349445,
|
||||
26.868799111,
|
||||
27.042173361,
|
||||
27.446639331,
|
||||
28.100783371,
|
||||
28.249282315,
|
||||
28.792045848,
|
||||
28.998001125,
|
||||
29.170862984,
|
||||
29.354634960,
|
||||
29.560513659,
|
||||
29.774344974,
|
||||
};
|
||||
|
|
22
patterns.c
22
patterns.c
|
@ -36,6 +36,23 @@ pattern_copy3left(struct s_game *g) {
|
|||
pattern_copyleft_spec(g, 0);
|
||||
}
|
||||
|
||||
void
|
||||
pattern_le_decafeine(struct s_game *g) {
|
||||
int times, i;
|
||||
int max_dist = get_max_obs_dist(g);
|
||||
int cleared_face = rand() % g->polygon_type;
|
||||
|
||||
for(i = 0; i < 5; i++) {
|
||||
for(times = 0; times < g->polygon_type; times+=2) {
|
||||
struct s_obstacle o;
|
||||
o = create_obstacle(SHAPE_THICK,
|
||||
(times + cleared_face)%g->polygon_type,
|
||||
1, max_dist + K_CLEARANCE + i*K_CLEARANCE/2);
|
||||
add_obstacle(g, o);
|
||||
}
|
||||
cleared_face = (cleared_face+1)%g->polygon_type;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pattern_opposing_forces(struct s_game *g) {
|
||||
|
@ -87,12 +104,13 @@ pattern_schenille(struct s_game *g) {
|
|||
|
||||
void
|
||||
add_pattern(struct s_game *g) {
|
||||
int n_patterns = 5;
|
||||
int n_patterns = 6;
|
||||
void (*patterns[])(struct s_game *g) = {pattern_copyleft,
|
||||
pattern_schenille,
|
||||
pattern_copy3left,
|
||||
pattern_opposing_forces,
|
||||
pattern_3opposing_forces};
|
||||
pattern_3opposing_forces,
|
||||
pattern_le_decafeine};
|
||||
|
||||
int choosen_pattern = rand() % n_patterns;
|
||||
|
||||
|
|
55
polygons.c
55
polygons.c
|
@ -39,6 +39,61 @@ draw_hexagon_side(struct s_game *g, int faceno, int dist, int thick, int col) {
|
|||
to_screen_coords(g, p4)} ;
|
||||
SDL_FillPolygon(g->screen, points, 4, col);
|
||||
}//}}}
|
||||
|
||||
SDL_Point
|
||||
get_square_vertice(int faceno, int dist) { //{{{
|
||||
SDL_Point p1;
|
||||
|
||||
p1.x = dist * cos((M_PI/2)*faceno);
|
||||
p1.y = dist * sin((M_PI/2)*faceno);
|
||||
|
||||
OFFSET_POINT(p1);
|
||||
|
||||
return p1;
|
||||
} //}}}
|
||||
void
|
||||
draw_square_side(struct s_game *g, int faceno, int dist, int thick, int col) { //{{{
|
||||
SDL_Point p1, p2, p3, p4;
|
||||
|
||||
p1 = get_square_vertice(faceno, dist);
|
||||
p2 = get_square_vertice(faceno+1, dist);
|
||||
p3 = get_square_vertice(faceno+1, dist+thick);
|
||||
p4 = get_square_vertice(faceno, dist+thick);
|
||||
|
||||
SDL_Point points[4] = {to_screen_coords(g, p1),
|
||||
to_screen_coords(g, p2),
|
||||
to_screen_coords(g, p3),
|
||||
to_screen_coords(g, p4)} ;
|
||||
SDL_FillPolygon(g->screen, points, 4, col);
|
||||
}//}}}
|
||||
|
||||
SDL_Point
|
||||
get_triangle_vertice(int faceno, int dist) { //{{{
|
||||
SDL_Point p1;
|
||||
|
||||
p1.x = dist * cos((2*M_PI/3)*faceno);
|
||||
p1.y = dist * sin((2*M_PI/3)*faceno);
|
||||
|
||||
OFFSET_POINT(p1);
|
||||
|
||||
return p1;
|
||||
} //}}}
|
||||
void
|
||||
draw_triangle_side(struct s_game *g, int faceno, int dist, int thick, int col) { //{{{
|
||||
SDL_Point p1, p2, p3, p4;
|
||||
|
||||
p1 = get_triangle_vertice(faceno, dist);
|
||||
p2 = get_triangle_vertice(faceno+1, dist);
|
||||
p3 = get_triangle_vertice(faceno+1, dist+thick);
|
||||
p4 = get_triangle_vertice(faceno, dist+thick);
|
||||
|
||||
SDL_Point points[4] = {to_screen_coords(g, p1),
|
||||
to_screen_coords(g, p2),
|
||||
to_screen_coords(g, p3),
|
||||
to_screen_coords(g, p4)} ;
|
||||
SDL_FillPolygon(g->screen, points, 4, col);
|
||||
}//}}}
|
||||
|
||||
void
|
||||
draw_polygon(struct s_game *g) { //{{{
|
||||
int faces;
|
||||
|
|
|
@ -13,5 +13,11 @@ draw_polygon(struct s_game *g);
|
|||
void
|
||||
draw_hexagon_side(struct s_game *g, int faceno, int dist, int thick, int col);
|
||||
|
||||
void
|
||||
draw_square_side(struct s_game *g, int faceno, int dist, int thick, int col);
|
||||
|
||||
void
|
||||
draw_triangle_side(struct s_game *g, int faceno, int dist, int thick, int col);
|
||||
|
||||
#endif /* ndef POLYGONS_H */
|
||||
|
||||
|
|
Loading…
Reference in a new issue