summaryrefslogtreecommitdiff
path: root/include/painter.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/painter.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/painter.h')
-rw-r--r--include/painter.h47
1 files changed, 36 insertions, 11 deletions
diff --git a/include/painter.h b/include/painter.h
index 7bcb47a..fc01092 100644
--- a/include/painter.h
+++ b/include/painter.h
@@ -1,15 +1,40 @@
-void painter_set_window(sfRenderWindow *window);
+/*
+ * painter.h
+ *
+ * Painter is a module for drawing tetris objects on a window. It is implemented
+ * as a singletone as OO programmers speak. It internally has global static
+ * arrays for objects referenced by handles. You register an object and get a
+ * handle (id) which can be used for updating an object - modifying it's
+ * drawable representation. Painter is used as described in following steps:
+ *
+ * 1. At first assign a window via painter_set_window() function.
+ * 2. Load a font if you are going to draw any text.
+ * 3. Register an object (field, text, etc.) using painter_register_*()
+ * function.
+ * 4. Update an object attribute using painter_update_*() function. Update all
+ * your objects for next frame before drawing.
+ * 5. Draw everything using painter_draw() function. Objects are drawn in order
+ * they were registered.
+ * 6. At the end you must destroy your drawable objects and fonts. Objects are
+ * registered each in it's own way, but have unified interface for
+ * destroying - painter_destroy_drawable() function. You can destroy them
+ * all at once using painter_destroy_drawables() function or even destroy
+ * everything that has been allocated by the Painter, even loaded fonts.
+ *
+ * */
-void painter_load_font(char *filename);
-void painter_destroy_font();
+void painter_set_window(sfRenderWindow *window);
-unsigned long painter_register_field(struct field *fld);
-void painter_update_field(unsigned long id, struct field *fld);
-unsigned long painter_register_text(struct text *txt);
-void painter_update_text(unsigned long id, struct text *txt);
+void painter_load_font(char *filename);
+void painter_destroy_font();
-void painter_draw();
+size_t painter_register_field(struct field *fld);
+void painter_update_field(size_t id, struct field *fld);
+size_t painter_register_text(struct text *txt);
+void painter_update_text(size_t id, struct text *txt);
-void painter_destroy_drawable(unsigned long id);
-void painter_destroy_drawables();
-void painter_destroy_all();
+void painter_draw();
+
+void painter_destroy_drawable(size_t id);
+void painter_destroy_drawables();
+void painter_destroy_all();