aboutsummaryrefslogtreecommitdiff
path: root/plugins/score/score.c
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-06-10 21:28:01 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-06-10 21:28:01 +0200
commit76d78db55969fa0a3ca92376e5cc9d0b266b4d1e (patch)
tree631273574db6582b3839158308a7f696ee3b7e46 /plugins/score/score.c
parent149848dbfa136f828b09253f402de59c00a5a1cf (diff)
downloaddungeon_game-76d78db55969fa0a3ca92376e5cc9d0b266b4d1e.tar.xz
Modularize rendering
Diffstat (limited to 'plugins/score/score.c')
-rw-r--r--plugins/score/score.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/score/score.c b/plugins/score/score.c
new file mode 100644
index 0000000..7ad8b66
--- /dev/null
+++ b/plugins/score/score.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include "../game/game.h"
+
+static int score = 0;
+
+void add_score(int s)
+{
+ score += s;
+}
+
+int get_score()
+{
+ return score;
+}
+
+static void render_score(struct winsize ws)
+{
+ (void) ws;
+
+ printf("\e[32m\e[3mScore:\e[23m %d", score);
+}
+
+__attribute__ ((constructor)) static void init()
+{
+ register_render_component(&render_score);
+}