summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-04 21:43:12 +0100
committerkdx <kikoodx@paranoici.org>2023-03-04 21:43:12 +0100
commit38fab9a43da7521c65a0fc5efec4da8aaa372844 (patch)
tree57d41f19c129f7bfc5297c0462e4abd43106d40b
parent02388bd54e91491e0e357d889209ed67eafb57fc (diff)
download7drl2023-38fab9a43da7521c65a0fc5efec4da8aaa372844.tar.gz
-rw-r--r--choice.c18
-rw-r--r--choice.h4
-rw-r--r--dialog.c9
-rw-r--r--dialog.h1
-rw-r--r--font.c13
-rw-r--r--font.h2
-rw-r--r--main.c7
-rw-r--r--res/font.pngbin3695 -> 4572 bytes
8 files changed, 46 insertions, 8 deletions
diff --git a/choice.c b/choice.c
new file mode 100644
index 0000000..4e7576d
--- /dev/null
+++ b/choice.c
@@ -0,0 +1,18 @@
+#include "choice.h"
+#include "dialog.h"
+
+void choice_begin(const char *s)
+{
+ dialog_set("\nG");
+ for (int i = 0; s[i] != '\0'; i++) {
+ dialog_set((char[]){ s[i], '\0' });
+ if (s[i + 1] != '\0')
+ dialog_set("D/G");
+ }
+ dialog_set("\nR> W");
+}
+
+char choice_result(void)
+{
+ return '\0';
+}
diff --git a/choice.h b/choice.h
new file mode 100644
index 0000000..b65844b
--- /dev/null
+++ b/choice.h
@@ -0,0 +1,4 @@
+#pragma once
+
+void choice_begin(const char *s);
+char choice_result(void);
diff --git a/dialog.c b/dialog.c
index 814bbc1..c94809b 100644
--- a/dialog.c
+++ b/dialog.c
@@ -3,12 +3,12 @@
#include "TZR.h"
#include <stdio.h>
-static const char *___dialog;
+static char ___dialog[1024];
static int ___cursor;
void dialog_set(const char *s)
{
- ___dialog = s;
+ strcat(___dialog, s);
}
void dialog_update(void)
@@ -26,3 +26,8 @@ void dialog_draw(void)
{
font_draw(0, 0, ___dialog, ___cursor);
}
+
+int dialog_done(void)
+{
+ return ___dialog[___cursor] == '\0';
+}
diff --git a/dialog.h b/dialog.h
index 531b7f0..18598a8 100644
--- a/dialog.h
+++ b/dialog.h
@@ -3,3 +3,4 @@
void dialog_set(const char *s);
void dialog_update(void);
void dialog_draw(void);
+int dialog_done(void);
diff --git a/font.c b/font.c
index 1f6d7e5..90acaee 100644
--- a/font.c
+++ b/font.c
@@ -16,8 +16,9 @@ void font_draw(int x, int y, const char *s, int size)
const int ox = x;
TZR_DrawSetColor(1, 1, 1, 1);
for (; *s != '\0' && size > 0; s++, size--) {
- const int ix = *s % 16 * 8;
- const int iy = *s / 16 * 16;
+ const char c = toupper(*s);
+ const int ix = c % 16 * FONT_W;
+ const int iy = c / 16 * FONT_H;
switch (*s) {
case '\n':
y += 1;
@@ -35,13 +36,17 @@ void font_draw(int x, int y, const char *s, int size)
case 'W':
TZR_DrawSetColor(1, 1, 1);
break;
+ case 'D':
+ TZR_DrawSetColor(0.5, 0.5, 0.5);
+ break;
default:
- TZR_DrawImage(___font_spr, x*8, y*16, ix, iy, 8, 16);
+ TZR_DrawImage(___font_spr, x*FONT_W, y*FONT_H, ix, iy,
+ FONT_W, FONT_H);
x += 1;
break;
}
}
TZR_DrawSetColor(1, 1, 1);
if (TZR_GetTick() / 30 % 2)
- TZR_DrawRectangle(true, x*8, y*16+1, 1, 14);
+ TZR_DrawRectangle(true, x*FONT_W, y*FONT_H+1, 1, FONT_H-2);
}
diff --git a/font.h b/font.h
index 52de1aa..d1494d0 100644
--- a/font.h
+++ b/font.h
@@ -1,4 +1,6 @@
#pragma once
+#define FONT_W 16
+#define FONT_H 32
int font_init(const char *path);
void font_draw(int x, int y, const char *s, int size);
diff --git a/main.c b/main.c
index 5af031d..6381f68 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,7 @@
#include "TZR.h"
#include "font.h"
#include "dialog.h"
+#include "choice.h"
static int init(void);
static void deinit(void);
@@ -20,7 +21,8 @@ int main(int argc, char **argv)
return 1;
}
- dialog_set("yo Rboi\nByou WcoolR!");
+ dialog_set("yo BnormieW\njsuis Bweird_gusW\ntu me replacesG?");
+ choice_begin("on");
while (!TZR_ShouldQuit()) {
TZR_CycleEvents();
@@ -37,7 +39,8 @@ int main(int argc, char **argv)
static int init(void)
{
- if (TZR_Init(.pixel_perfect=false, .title="7DRL 2023"))
+ if (TZR_Init(.width=512, .height=448, .pixel_perfect=false,
+ .title="7DRL 2023"))
return 1;
if (font_init("res/font.png"))
return 1;
diff --git a/res/font.png b/res/font.png
index 067b801..cdfdaa9 100644
--- a/res/font.png
+++ b/res/font.png
Binary files differ