aboutsummaryrefslogtreecommitdiff
path: root/src/instance/inc/instance.h
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2021-07-03 00:49:03 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-03-30 08:20:20 +0200
commit6b9f686913efc3725b2690033cd4f398e07076ba (patch)
treee9aa91a6b9f617d78123ebe7ad272fc42a60d306 /src/instance/inc/instance.h
parentc9e6ae44a9aeb89b3f48f3443d6baa80103f7445 (diff)
downloadjancity-6b9f686913efc3725b2690033cd4f398e07076ba.tar.gz
Add project source code
Diffstat (limited to 'src/instance/inc/instance.h')
-rw-r--r--src/instance/inc/instance.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/instance/inc/instance.h b/src/instance/inc/instance.h
new file mode 100644
index 0000000..ca8a606
--- /dev/null
+++ b/src/instance/inc/instance.h
@@ -0,0 +1,68 @@
+#ifndef INSTANCE_H
+#define INSTANCE_H
+
+#include <camera.h>
+#include <gfx.h>
+#include <util.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef unsigned int instance_hp;
+
+struct instance
+{
+ bool alive, dying;
+ unsigned int hp;
+ struct util_rect r;
+};
+
+typedef bool (*instance_attacked_cb)(struct instance *i, unsigned int ap);
+typedef bool (*instance_sheltered_cb)(struct instance *self, struct instance *other);
+typedef void (*instance_done_cb)(struct instance *i, void *op);
+
+struct instance_render_cfg
+{
+ const struct instance *i;
+ const struct camera *cam;
+ enum
+ {
+ INSTANCE_RENDER_CFG_SPRITE,
+ INSTANCE_RENDER_CFG_QUAD
+ } prim_type;
+
+ union
+ {
+ struct sprite *s;
+ const struct instance_render_quad
+ {
+ struct quad *q;
+ short w, h;
+ uint8_t u;
+ bool xflip;
+ } *quad;
+ } prim;
+
+ bool sel;
+ instance_hp max_hp;
+ const struct instance_render_off
+ {
+ short x, y;
+ } *off;
+};
+
+bool instance_attacked(struct instance *self, unsigned int ap);
+void instance_clear_pools(void);
+int instance_render(const struct instance_render_cfg *cfg);
+int instance_render_target(const struct instance *const i, const struct camera *cam);
+void instance_cyclic(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* INSTANCE_H */