summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile2
-rw-r--r--curses.c2
-rw-r--r--dartboat.c (renamed from dartbot.c)5
-rw-r--r--web/dartboat_wasm.c8
-rw-r--r--web/static/index.html2
-rw-r--r--web/svg.c (renamed from web/svg_dartboard.c)14
-rw-r--r--web/svg.h7
8 files changed, 25 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index 09ca33a..dca8006 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
-dartbot
+dartboat
*.d
*.o
diff --git a/Makefile b/Makefile
index 83ec0a8..3ffd796 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CFLAGS += -O2 -Wall -Wextra -Wpedantic
CPPFLAGS += -MMD -MP
LDFLAGS += -lm -lncurses
-TARGET := dartbot
+TARGET := dartboat
SRC := $(wildcard *.c)
OBJ := $(SRC:.c=.o)
diff --git a/curses.c b/curses.c
index 4169906..12141af 100644
--- a/curses.c
+++ b/curses.c
@@ -21,7 +21,7 @@ void init_curses()
promptw = newwin(1, COLS, LINES-1, 0);
wbkgd(titlew, COLOR_PAIR(C_STATUS));
wbkgd(statw, COLOR_PAIR(C_STATUS));
- waddstr(titlew, " dartbot");
+ waddstr(titlew, " dartboat");
wrefresh(titlew);
}
diff --git a/dartbot.c b/dartboat.c
index 1759846..aa59630 100644
--- a/dartbot.c
+++ b/dartboat.c
@@ -118,12 +118,13 @@ void curses_match(int start_points, char *n1, void (*f1)(struct leg *),
void cvc_curses_match(int start_points)
{
- curses_match(start_points, "Dartbot 1", comp_visit, "Dartbot 2", comp_visit);
+ curses_match(start_points, "Dartboat 1", comp_visit, "Dartboat 2",
+ comp_visit);
}
void pvc_curses_match(int start_points)
{
- curses_match(start_points, "David", user_visit, "Dartbot", comp_visit);
+ curses_match(start_points, "David", user_visit, "Dartboat", comp_visit);
}
void pvp_curses_match(int start_points)
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c
index 21d13fd..b4d232a 100644
--- a/web/dartboat_wasm.c
+++ b/web/dartboat_wasm.c
@@ -1,3 +1,5 @@
+#include "svg.h"
+
#include "checkouts.h"
#include "comp.h"
@@ -157,7 +159,6 @@ EMSCRIPTEN_KEEPALIVE void update_user_rem_from_pts(int pts)
update_player_rem(state->active_player, state->active_leg->rem - pts);
}
-void draw_point(double, double);
EMSCRIPTEN_KEEPALIVE void draw_boat_throwing(int pts, char *str, double x, double y)
{
char pts_str[10];
@@ -167,7 +168,7 @@ EMSCRIPTEN_KEEPALIVE void draw_boat_throwing(int pts, char *str, double x, doubl
state->legs[1]->visits[state->legs[1]->n_visits-2].rem :
state->legs[1]->start;
- draw_point(x, y);
+ svg_draw_point(x, y);
update_player_rem(2, rem - pts);
EM_ASM({setPromptInput($0)}, pts_str);
EM_ASM({promptMsgR($0)}, str);
@@ -461,12 +462,11 @@ EMSCRIPTEN_KEEPALIVE void set_stdev(float stdev)
horizontal_stdev = vertical_stdev = stdev;
}
-void draw_board();
void init_boat()
{
srand(time(NULL));
init_board();
- draw_board();
+ svg_draw_board();
EM_ASM(readOpts());
EM_ASM({updateDelay($0)}, delay_ms);
diff --git a/web/static/index.html b/web/static/index.html
index c1a2fdd..f583449 100644
--- a/web/static/index.html
+++ b/web/static/index.html
@@ -85,7 +85,7 @@
<p>To avoid destructive actions being a misclick away, certain actions require two presses—one to activate the button and another to trigger it.</p>
<p>The controls are designed to be keyboard-friendly. The keys should be fairly intuitive for the most part.</p>
<h2>Info</h2>
- <p>dartboat is <a href="https://retarded.software/dartbot.git/" target="_blank">free and open-source software</a>. It is written in C and compiled to WebAssembly for the web target. JavaScript is used to handle the interactive elements.</p>
+ <p>dartboat is <a href="https://retarded.software/dartboat.git/" target="_blank">free and open-source software</a>. It is written in C and compiled to WebAssembly for the web target. JavaScript is used to handle the interactive elements.</p>
</div>
</div>
</body>
diff --git a/web/svg_dartboard.c b/web/svg.c
index 1125ef0..6744ac6 100644
--- a/web/svg_dartboard.c
+++ b/web/svg.c
@@ -1,3 +1,5 @@
+#include "svg.h"
+
#include "board.h"
#include "comp.h"
@@ -19,10 +21,8 @@
struct elem {
char *name;
- int n_attrs;
- int size_attrs;
- char **attr_names;
- char **attr_vals;
+ int n_attrs, size_attrs;
+ char **attr_names, **attr_vals;
char *content;
};
@@ -215,9 +215,9 @@ void draw_elemv(int layer, int elemc, struct elem **elemv)
offsetof(struct elem, content));
}
-void draw_board()
+void svg_draw_board()
{
- struct elem **elemv = malloc(500 * sizeof(*elemv));
+ struct elem **elemv = malloc(200 * sizeof(*elemv));
int elemc = 0;
elemv[elemc++] = gen_circle(DIAMETER/2, C_BLACK);
@@ -244,7 +244,7 @@ void draw_board()
free(elemv);
}
-void draw_point(double x, double y) {
+void svg_draw_point(double x, double y) {
struct elem *e = gen_circle(8, "#33f");
elem_add_attr(e, "stroke", "#ff0");
elem_add_attr(e, "stroke-width", "2");
diff --git a/web/svg.h b/web/svg.h
new file mode 100644
index 0000000..3321846
--- /dev/null
+++ b/web/svg.h
@@ -0,0 +1,7 @@
+#ifndef SVG_H
+#define SVG_H
+
+void svg_draw_board();
+void svg_draw_point(double x, double y);
+
+#endif