summaryrefslogtreecommitdiffstats
path: root/src/char/char.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/char/char.h')
-rw-r--r--src/char/char.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/char/char.h b/src/char/char.h
new file mode 100644
index 0000000..f6c6b9f
--- /dev/null
+++ b/src/char/char.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2021 P. J. McDermott
+ *
+ * This file is part of Maze Fight
+ *
+ * Maze Fight is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Maze Fight is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Maze Fight. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MF_CHAR_CHAR_H
+#define MF_CHAR_CHAR_H
+
+enum _mf_char_dir {
+ MF_CHAR_DIR_N_,
+ MF_CHAR_DIR_U_,
+ MF_CHAR_DIR_D_,
+ MF_CHAR_DIR_L_,
+ MF_CHAR_DIR_R_
+};
+
+struct mf_char {
+ struct mf_maze *maze;
+ int cell_width;
+ int speed;
+ enum _mf_char_dir cur_dir;
+ enum _mf_char_dir new_dir;
+ enum _mf_char_dir old_dir;
+ int turning;
+ int turn_time;
+ int cur_x;
+ int cur_y;
+ int new_x;
+ int new_y;
+ int travel;
+ int padding;
+ double smile_y;
+ double smile_r;
+ double eye_x;
+ double eye_y;
+ double eye_r;
+ SDL_Color head_color;
+ SDL_Color smil_color;
+ SDL_Color eyes_color;
+ int (*update)(struct mf_char *);
+ int (*render)(struct mf_char *, SDL_Renderer *);
+ void (*destroy)(struct mf_char *);
+};
+
+struct mf_char *
+mf_char_new(size_t size);
+
+#define mf_char_init(c, t_c, name) \
+ do { \
+ c = mf_char_new(sizeof(struct mf_##name)); \
+ if (c == NULL) { \
+ return NULL; \
+ }; \
+ c->update = &_mf_##name##_update; \
+ c->render = &_mf_##name##_render; \
+ c->destroy = &_mf_##name##_destroy; \
+ t_c = (struct mf_##name *) c; \
+ } while (0)
+
+#endif /* MF_CHAR_CHAR_H */