Fix zigzagon pattern

This commit is contained in:
CaptainGobelin 2015-01-02 15:39:55 +01:00
parent 36560d067f
commit 0a95cf402a
4 changed files with 14 additions and 12 deletions

View file

@ -17,7 +17,7 @@ has_collision(struct s_game *g, struct s_obstacle o) {
if(face != o.face)
return 0;
if(o.distance <= CURSOR_DIST &&
if((MAX(0, o.distance)) <= CURSOR_DIST &&
o.distance + o.thick >= CURSOR_DIST) {
return 1;
}

View file

@ -38,6 +38,7 @@
#define OFFSET_POINT(p) {p.x += SCREEN_WIDTH/2; p.y += SCREEN_HEIGHT/2;}
#define MAX(a, b) (a < b) ? (b) : (a)
#define MIN(a, b) (a < b) ? (a) : (b)
#define TO_DEG(x) (x*ANGLE_MAX/360)
#define TO_RAD(x) (x * 2 * M_PI / ANGLE_MAX)

View file

@ -67,7 +67,8 @@ draw_obstacles(struct s_game *g) { //{{{
for(i = 0; i < g->num_obs; i++) {
if(g->obs[i].used) {
struct s_obstacle o = g->obs[i];
draw_polygon_side(g, o.face, o.distance, o.thick, g->color);
int effective_dist = MAX(0, o.distance);
draw_polygon_side(g, o.face, effective_dist, o.thick + (MIN(0, o.distance)), g->color);
}
}
} //}}}
@ -80,7 +81,7 @@ update_obstacles(struct s_game *g) { //{{{
g->obs[i].distance -= DFT_OBS_SPEED*g->obs[i].speed;
g->obs[i].thick = 1 * g->sexual_pulsation + g->obs[i].original_thick;
if(g->obs[i].distance <= 0)
if(g->obs[i].distance+g->obs[i].thick <= 0)
g->obs[i].used = 0;
}
}

View file

@ -112,32 +112,32 @@ pattern_zigzagone(struct s_game *g) {
int perim;
for(perim = 0; perim < g->polygon_type/2; perim++) {
for(perim = 1; perim < 1+g->polygon_type/2; perim++) {
int face = (cleared_face + perim)%g->polygon_type;
struct s_obstacle o;
o = create_obstacle(SHAPE_THICK,
(perim + cleared_face)%g->polygon_type,
face,
1, max_dist + K_CLEARANCE);
add_obstacle(g, o);
o = create_obstacle(SHAPE_THICK,
(perim + cleared_face)%g->polygon_type,
1, max_dist + 3*K_CLEARANCE + 2*SHAPE_THICK);
face,
1, max_dist + K_CLEARANCE + 2*(K_CLEARANCE/2 + SHAPE_THICK));
add_obstacle(g, o);
face -= 3;
CLEVER_MODULO(face, g->polygon_type/2);
face = (cleared_face - perim);
CLEVER_MODULO(face, g->polygon_type);
o = create_obstacle(SHAPE_THICK,
(perim + cleared_face)%g->polygon_type,
1, max_dist + 2*K_CLEARANCE + 1*SHAPE_THICK);
face,
1, max_dist + K_CLEARANCE + 1*(K_CLEARANCE/2 + SHAPE_THICK));
add_obstacle(g, o);
}
struct s_obstacle o;
o = create_obstacle((SHAPE_THICK+K_CLEARANCE)*3,
o = create_obstacle((SHAPE_THICK+K_CLEARANCE/2)*2 + SHAPE_THICK,
cleared_face,
1, max_dist + K_CLEARANCE);
add_obstacle(g, o);