From b4911c2abfa513e91c82a712ef277f7e6209b502 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 18 Apr 2020 20:29:15 -0700 Subject: *: 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. --- src/play.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/play.h (limited to 'src/play.h') 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 - + * + * 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 . + */ + +#ifndef _PLAY_H +#define _PLAY_H + +#include + +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 -- cgit v1.2.3