summaryrefslogtreecommitdiff
path: root/include/field.h
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2018-12-06 05:24:30 +0300
committerOxore <oxore@protonmail.com>2018-12-06 07:59:07 +0300
commit80ff7b315a6b5a9f9c62de5c6b03f52ddf099837 (patch)
treeb8b982e702ac5a64db40116e39fd453e998b3dbd /include/field.h
parent80325e9dfaece1316fa5cdc2b0551280369c4f7d (diff)
Add simple documentation in comments, refactor.
Change all `unsigned int` and `unsigned long` types to `size_t`. Fix names alignment in headers. Add documentation and simple description: Painter - painter.h Main - tetris.c Unicode - unicode.h IDList - idlist.h Engine - engine.c Minor changes: tetris.c - fix indentation and code blocks separation with newlines, remove unused includes. idlist.h - fix structure field name alignment. field.h, engine.c - define aliases for ghost and active shapes indexes in the field. engine.c - rename menuTick to snake case, fix curly braces style of functions. Makefile - switch SFML deprecated warnings off.
Diffstat (limited to 'include/field.h')
-rw-r--r--include/field.h63
1 files changed, 33 insertions, 30 deletions
diff --git a/include/field.h b/include/field.h
index c63a836..4e97aa8 100644
--- a/include/field.h
+++ b/include/field.h
@@ -3,9 +3,12 @@
#define SHP_ATTR_GHOST (1 << 0)
+#define GHOST_SHAPE_INDEX 0
+#define ACTIVE_SHAPE_INDEX 1
+
struct cell {
- char a; // active/empty state of cell
- unsigned int color;
+ char a; // active/empty state of cell
+ size_t color;
};
/*
@@ -26,36 +29,36 @@ struct cell {
*/
struct shape {
- struct vector2i; // position
- int t; // shape type
- unsigned int attr;
- char c[4][4];
+ struct vector2i; // position
+ int t; // shape type
+ size_t attr;
+ char c[4][4];
};
struct field {
- unsigned long id;
- unsigned int attr;
- struct vector2i pos;
- struct vector2ui size;
- struct vector2ui bound;
- struct cell **c; // array of logic shape cells
- unsigned int shape_cnt;
- struct shape *shape;
+ size_t id;
+ size_t attr;
+ struct vector2i pos;
+ struct vector2ui size;
+ struct vector2ui bound;
+ struct cell **c; // array of logic shape cells
+ size_t shape_cnt;
+ struct shape *shape;
};
-void field_init(struct field *fld);
-void field_deinit(struct field *fld);
-void field_fill_random(struct field *fld);
-void field_clear(struct field *fld);
-void field_rotate_shape_clockwise(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);
-int field_shape_collision(struct field *fld, struct shape *shape);
-int field_shape_out_of_bounds(struct field *fld, struct shape *shape);
-
-void shape_load(struct shape *shape);
-void shape_gen_random(struct shape *shape);
+void field_init(struct field *fld);
+void field_deinit(struct field *fld);
+void field_fill_random(struct field *fld);
+void field_clear(struct field *fld);
+void field_rotate_shape_clockwise(struct field *fld, size_t index);
+int field_move_shape_down(struct field *fld, size_t index);
+int field_move_shape_left(struct field *fld, size_t index);
+int field_move_shape_right(struct field *fld, size_t index);
+void field_put_shape(struct field *fld, struct shape *shape);
+void field_reset_walking_shape(struct field *fld, size_t index);
+int field_rm_lines(struct field *fld);
+int field_shape_collision(struct field *fld, struct shape *shape);
+int field_shape_out_of_bounds(struct field *fld, struct shape *shape);
+
+void shape_load(struct shape *shape);
+void shape_gen_random(struct shape *shape);