summaryrefslogtreecommitdiff
path: root/src/play.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-04-18 20:29:15 -0700
committerVito Caputo <vcaputo@pengaru.com>2020-04-19 03:27:39 -0700
commitb4911c2abfa513e91c82a712ef277f7e6209b502 (patch)
tree4ee41f6fc432d15147f0bf7e18b032d01efe2231 /src/play.h
*: initial commit
This is largely ripped out of Eon to try give a reusable scaffolding for accelerating SDL-based simple game development. I expect there to be future commits adding more configurability like a means of influencing which flags are passed to SDL_Init(), e.g. if you have no need for joystick support, don't pass in that flag, and libplay won't pass it to SDL_Init() and do the joystick opening/mapping dance, etc.
Diffstat (limited to 'src/play.h')
-rw-r--r--src/play.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/play.h b/src/play.h
new file mode 100644
index 0000000..0f1d2da
--- /dev/null
+++ b/src/play.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 - Vito Caputo - <vcaputo@pengaru.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3 as published
+ * by the Free Software Foundation.
+ *
+ * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _PLAY_H
+#define _PLAY_H
+
+#include <SDL.h>
+
+typedef enum play_ticks_t {
+ PLAY_TICKS_TIMER0,
+ PLAY_TICKS_TIMER1,
+ PLAY_TICKS_TIMER2,
+ PLAY_TICKS_TIMER3,
+ PLAY_TICKS_TIMER4,
+ PLAY_TICKS_TIMER5,
+ PLAY_TICKS_TIMER6,
+ PLAY_TICKS_TIMER7,
+ PLAY_TICKS_TIMER8,
+ PLAY_TICKS_TIMER9,
+ PLAY_TICKS_CNT
+} play_ticks_t;
+
+#define PLAY_MUSIC_FLAG_LOOP (1L)
+#define PLAY_MUSIC_FLAG_FADEIN (1L << 1)
+#define PLAY_MUSIC_FLAG_OPTIONAL (1L << 2)
+#define PLAY_MUSIC_FLAG_QUEUE (1L << 3)
+#define PLAY_MUSIC_FLAG_IDEMPOTENT (1L << 4)
+
+typedef struct play_t play_t;
+
+typedef struct play_ops_t {
+ void * (*init)(play_t *play, int argc, char *argv[]);
+ void (*destroy)(play_t *play, void *context);
+ void (*enter)(play_t *play, void *context);
+ void (*leave)(play_t *play, void *context);
+ void (*update)(play_t *play, void *context);
+ void (*render)(play_t *play, void *context);
+ void (*dispatch)(play_t *play, void *context, SDL_Event *event);
+} play_ops_t;
+
+play_t * play_startup(int argc, char *argv[], const play_ops_t *ops[]);
+int play_shutdown(play_t *play);
+void play_run(play_t *play);
+
+void play_music_set(play_t *play, unsigned flags, const char *fmt, ...);
+void play_music_pause(play_t *play);
+void play_music_resume(play_t *play);
+void play_context_enter(play_t *play, int context);
+void * play_context(play_t *play, int context);
+unsigned play_ticks(play_t *play, play_ticks_t timer);
+void play_ticks_reset(play_t *play, play_ticks_t timer);
+void play_ticks_pause(play_t *play);
+int play_ticks_elapsed(play_t *play, play_ticks_t timer, unsigned duration);
+void play_quit(play_t *play);
+
+#endif
© All Rights Reserved