diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/dartboat_wasm.c | 8 | ||||
-rw-r--r-- | web/static/index.html | 2 | ||||
-rw-r--r-- | web/svg.c (renamed from web/svg_dartboard.c) | 14 | ||||
-rw-r--r-- | web/svg.h | 7 |
4 files changed, 19 insertions, 12 deletions
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 |