#ifndef GAME_H #define GAME_H #include "AssetManager.h" #include "ObjectStore.h" #include "Renderer.h" #include "SDL_pixels.h" #include "Window.h" #include "reusable_ids.h" #include #include #ifdef __cplusplus extern "C" { #endif // !__cplusplus // GENERAL ENGINE API /** * Initialises the game engine. Returns true on success and false on failure. * * The audio_tracks parameter determines how many audio tracks to be allocated. * Pass 0 if you want to allocate the default number. */ bool init_engine(const char *game_name, WindowSize window_size, SDL_Color window_background_color, bool full_screen, uint8_t audio_tracks); bool game_running(); void close_engine(); // END GENERAL ENGINE API // ASSET MANAGEMENT API ObjectID add_object(void *object, EventHandlerPtr eh, UpdateFuncPtr uf, RenderFuncPtr rf); void remove_object(ObjectID *id); // END ASSET MANAGEMENT API // ASSET MANAGEMENT API AssetID load_asset(const char *path, AssetType type); void close_asset(AssetID *id); // END ASSET MANAGEMENT API // RENDERING API /** * Returns the user-defined window size or the screen size when in full screen. */ WindowSize get_window_defined_size(); /** * Returns the actual window size which can be different from the user-defined * size or the screen size if the window is on a display that supports high DPI. */ WindowSize get_window_real_size(); /** * Returns the valid drawing area which can be a portion of the screen when * running in full screen mode and the width to height ratio of the user-defined * window size is different from the width to height ratio of the screen. */ WindowDrawingArea get_window_drawing_area(); void fill_rectangle(RenderRect rect, SDL_Color color); /** * Ensures that a rendered rectangle is clipped to the drawing area when it is * smaller than the actual size of the window. */ void clip_source_rect_to_drawing_area(RenderRect *src, RenderRect *dest); RenderRect get_texture_asset_rect(AssetID id); void render_texture_asset(AssetID id, RenderRect *src, RenderRect *dest); void render_text_with_font_asset(AssetID id, const char *text, float x, float y); void set_font_asset_size(AssetID id, uint32_t size); // END RENDERING API // AUDIO API int8_t play_audio_asset(AssetID id, int16_t loops, bool fade_in, uint32_t fade_length_in_ms); void pause_audio_asset_on_track(AssetID id, uint8_t track); void resume_audio_asset_on_track(AssetID id, uint8_t track); void stop_audio_asset_on_track(AssetID id, uint8_t track); void fade_out_audio_asset_on_track(AssetID id, uint8_t track, uint32_t fade_length_in_ms); void pause_all_instances_of_audio_asset(AssetID id); void resume_all_instances_of_audio_asset(AssetID id); void stop_all_instances_of_audio_asset(AssetID id); void fade_out_all_instances_of_audio_asset(AssetID id, uint32_t fade_length_in_ms); int8_t get_audio_asset_volume(AssetID id); void set_audio_asset_volume(AssetID id, int8_t volume); void play_music_asset(AssetID id, int16_t loops, bool fade_in, uint32_t fade_length_in_ms); void pause_music_asset(AssetID id); void resume_music_asset(AssetID id); void stop_music_asset(AssetID id); void fade_out_music_asset(AssetID id, uint32_t fade_length_in_ms); int8_t get_music_asset_volume(AssetID id); void set_music_asset_volume(AssetID id, int8_t volume); bool is_music_asset_playing(AssetID id); void pause_playing_music(); void resume_playing_music(); void stop_playing_music(); void fade_out_playing_music(uint32_t fade_length_in_ms); void set_playing_music_volume(int8_t volume); bool is_music_playing(); // END AUDIO API // GAME LOOP API void handle_events(); void update(); void render(); // END GAME LOOP API #ifdef __cplusplus } #endif // !__cplusplus #endif // !GAME_H