From a9e7132e6a430e86e8a69d1301252e38daf6e593 Mon Sep 17 00:00:00 2001 From: Oxore Date: Mon, 9 Jul 2018 02:43:50 +0300 Subject: Introduce phantom shape, refactor field Introduce phantom shape feature, yay! Refactor field: rename attribute of invisible empty cells, remove "color" member from struct shape, introduce shape movement functions with embedded collision checking and success reporting, --- include/field.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'include/field.h') diff --git a/include/field.h b/include/field.h index 30ed56b..52b4de8 100644 --- a/include/field.h +++ b/include/field.h @@ -1,5 +1,7 @@ -#define FLD_ATTR_INVISIBLE (1 << 0) -#define FLD_ATTR_TRANSPARENT (1 << 1) +#define FLD_ATTR_INVISIBLE (1 << 0) +#define FLD_ATTR_HIDE_EMPTY_CELLS (1 << 1) + +#define SHP_ATTR_GHOST (1 << 0) struct cell { char a; // active/empty state of cell @@ -24,11 +26,10 @@ struct cell { */ struct shape { - int x; // x coord of shape's left side - int y; // y coord of shape's bottom + struct vector2i; // position int t; // shape type - unsigned int color; // shape color - char c[4][4]; // array of logic shape cells + unsigned int attr; + char c[4][4]; }; struct field { @@ -47,6 +48,9 @@ void field_deinit(struct field *fld); void field_fill_random(struct field *fld); void field_clear(struct field *fld); void field_rotate_shape(struct field *fld, unsigned int index); +int field_move_shape_down(struct field *fld, unsigned int index); +int field_move_shape_left(struct field *fld, unsigned int index); +int field_move_shape_right(struct field *fld, unsigned int index); void field_put_shape(struct field *fld, struct shape *shape); void field_reset_walking_shape(struct field *fld, unsigned int index); int field_rm_lines(struct field *fld); -- cgit v1.2.3