summaryrefslogtreecommitdiff
path: root/include/field.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/field.h')
-rw-r--r--include/field.h66
1 files changed, 31 insertions, 35 deletions
diff --git a/include/field.h b/include/field.h
index f037d41..93f80f0 100644
--- a/include/field.h
+++ b/include/field.h
@@ -1,17 +1,18 @@
-#define FLD_SIZE_Y 22
-#define FLD_SIZE_X 10
-#define FLD_BOUND_Y FLD_SIZE_Y + 3
-#define FLD_BOUND_X FLD_SIZE_X
-#define FLD_POS (sfVector2i){.x = 10, .y = 10+550-24}
-#define FLD_SIZE (sfVector2f){.x = FLD_SIZE_X, .y = FLD_SIZE_Y}
-#define CELL_SIZE (sfVector2f){.x = 23, .y = 23}
+#define FLD_ATTR_INVISIBLE (1 << 0)
+#define FLD_ATTR_TRANSPARENT (1 << 1)
struct cell {
char a; // active/empty state of cell
- sfColor fColor; // fill color
unsigned int color;
};
+struct vector2i {
+ int x, y;
+};
+
+struct vector2ui {
+ unsigned int x, y;
+};
/*
* field + shape coord system
@@ -34,36 +35,31 @@ struct shape {
int x; // x coord of shape's left side
int y; // y coord of shape's bottom
int t; // shape type
- sfColor fColor; // shape color
+ unsigned int color; // shape color
char c[4][4]; // array of logic shape cells
- sfRectangleShape *p[4][4]; // array of physical shape cells
- int cOutThick; // shape rectangles outline thickness
- sfVector2f cSize; // shape rectangles size variable x/y
};
struct field {
- sfVector2i pos;
- struct cell c[FLD_BOUND_Y][FLD_SIZE_X]; // array of logic shape cells
- sfRectangleShape *p[FLD_SIZE_Y][FLD_SIZE_X]; // array of physical shape cells
- int cOutThick; // Field rectangles outline thickness
- sfVector2f cSize; // shape rectangles size variable x/y
- sfVector2i size;
- sfVector2i bound;
- unsigned int id;
+ 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;
};
-void init_field(struct field *fld);
-void colorize_field(struct field *fld);
-void colorize_field_random(struct field *fld);
-void colorize_active_shape(struct field *fld, struct shape *shape);
-void init_next_shape(struct shape *next);
-void putShape(struct field *fld, struct shape *active);
-int out_of_field(struct field *fld, struct shape *active);
-void load_shape(struct shape *shape);
-void rotate_shape(struct field *fld, struct shape *shape);
-int collide(struct field *fld, struct shape *active);
-void resetActiveShape(struct field *fld, struct shape *active);
-void gen_shape(struct shape *shape);
-int rm_lines(struct field *fld);
-void free_field(struct field *fld);
-void free_shape(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(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);