summaryrefslogtreecommitdiff
path: root/gfx-iso/app/isogfx-demo.c
diff options
context:
space:
mode:
Diffstat (limited to 'gfx-iso/app/isogfx-demo.c')
-rw-r--r--gfx-iso/app/isogfx-demo.c79
1 files changed, 0 insertions, 79 deletions
diff --git a/gfx-iso/app/isogfx-demo.c b/gfx-iso/app/isogfx-demo.c
deleted file mode 100644
index 9889275..0000000
--- a/gfx-iso/app/isogfx-demo.c
+++ /dev/null
@@ -1,79 +0,0 @@
1#include "isogfx-demo.h"
2
3#include <gfx/gfx_app.h>
4#include <isogfx/isogfx.h>
5
6#include <assert.h>
7#include <stdbool.h>
8#include <stdio.h>
9#include <stdlib.h>
10
11typedef struct State {
12 int xpick;
13 int ypick;
14 SpriteSheet stag_sheet;
15 Sprite stag;
16} State;
17
18static void shutdown(IsoGfx* iso, void* app_state) {
19 assert(iso);
20 if (app_state) {
21 free(app_state);
22 }
23}
24
25static void update(IsoGfx* iso, void* app_state, double t, double dt) {
26 assert(iso);
27 assert(app_state);
28 State* state = (State*)(app_state);
29
30 double mouse_x, mouse_y;
31 gfx_app_get_mouse_position(&mouse_x, &mouse_y);
32
33 isogfx_pick_tile(iso, mouse_x, mouse_y, &state->xpick, &state->ypick);
34
35 // printf("Picked tile: (%d, %d)\n", state->xpick, state->ypick);
36}
37
38static void render(IsoGfx* iso, void* app_state) {
39 assert(iso);
40 assert(app_state);
41 State* state = (State*)(app_state);
42
43 isogfx_render(iso);
44}
45
46bool make_demo_app(IsoGfx* iso, IsoGfxApp* app) {
47 assert(iso);
48 assert(app);
49
50 State* state = calloc(1, sizeof(State));
51 if (!state) {
52 return false;
53 }
54
55 if (!isogfx_load_world(iso, "/home/jeanne/assets/tilemaps/demo1.tm")) {
56 goto cleanup;
57 }
58
59 if (!isogfx_load_sprite_sheet(
60 iso, "/home/jeanne/assets/tilesets/scrabling/critters/stag/stag.ss",
61 &state->stag_sheet)) {
62 goto cleanup;
63 }
64
65 state->stag = isogfx_make_sprite(iso, state->stag_sheet);
66 isogfx_set_sprite_position(iso, state->stag, 5, 4);
67
68 app->pixel_scale = 2;
69 app->state = state;
70 app->shutdown = shutdown;
71 app->update = update;
72 app->render = render;
73
74 return true;
75
76cleanup:
77 free(state);
78 return false;
79}