libsuperderpy/src/main.h

167 lines
3.9 KiB
C
Raw Normal View History

2012-02-28 13:09:12 +01:00
/*! \file main.h
* \brief Headers of main file of SuperDerpy engine.
*
* Contains basic functions shared by all views.
*/
2012-02-16 15:40:58 +01:00
#ifndef MAIN_H
#define MAIN_H
#include <allegro5/allegro.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
2012-02-28 13:09:12 +01:00
/*! \brief Enum of all available gamestates. */
2012-02-16 15:40:58 +01:00
enum gamestate_enum {
GAMESTATE_LOADING,
GAMESTATE_MENU,
GAMESTATE_ABOUT,
GAMESTATE_INTRO,
2012-02-21 23:33:02 +01:00
GAMESTATE_MAP,
GAMESTATE_LEVEL
2012-02-16 15:40:58 +01:00
};
2012-02-28 13:09:12 +01:00
/*! \brief Resources used by Level state. */
2012-02-22 12:43:14 +01:00
struct Level {
2012-02-28 13:09:12 +01:00
ALLEGRO_BITMAP *fade_bitmap;
ALLEGRO_BITMAP *image;
ALLEGRO_BITMAP *derpy_walkcycle;
ALLEGRO_BITMAP *derpy;
ALLEGRO_BITMAP *derpytmp;
2012-02-22 12:43:14 +01:00
ALLEGRO_SAMPLE *sample;
2012-02-28 13:09:12 +01:00
int current_level;
int derpy_frame;
int derpy_frame_tmp;
double derpy_pos;
2012-02-22 12:43:14 +01:00
};
2012-02-28 13:09:12 +01:00
/*! \brief Resources used by Menu state. */
2012-02-16 15:40:58 +01:00
struct Menu {
2012-02-28 13:09:12 +01:00
ALLEGRO_BITMAP *menu_bitmap;
ALLEGRO_BITMAP *menu_fade_bitmap;
ALLEGRO_BITMAP *image;
ALLEGRO_BITMAP *cloud_bitmap;
ALLEGRO_BITMAP *cloud;
ALLEGRO_BITMAP *cloud2_bitmap;
ALLEGRO_BITMAP *cloud2;
ALLEGRO_BITMAP *pie;
ALLEGRO_BITMAP *pie_bitmap;
ALLEGRO_BITMAP *pinkcloud_bitmap;
ALLEGRO_BITMAP *pinkcloud;
ALLEGRO_BITMAP *rain;
ALLEGRO_BITMAP *mountain_bitmap;
ALLEGRO_BITMAP *mountain;
float cloud_position;
float cloud2_position;
2012-02-16 17:05:16 +01:00
int mountain_position;
2012-02-28 13:09:12 +01:00
ALLEGRO_SAMPLE *sample;
ALLEGRO_SAMPLE *rain_sample;
ALLEGRO_SAMPLE *click_sample;
ALLEGRO_FONT *font_title;
ALLEGRO_FONT *font_subtitle;
ALLEGRO_FONT *font;
ALLEGRO_FONT *font_selected;
int selected;
2012-02-17 00:06:01 +01:00
bool options;
2012-02-16 15:40:58 +01:00
};
2012-02-28 13:09:12 +01:00
/*! \brief Resources used by Loading state. */
2012-02-16 15:40:58 +01:00
struct Loading {
2012-02-28 13:09:12 +01:00
ALLEGRO_BITMAP *loading_bitmap;
ALLEGRO_BITMAP *image;
2012-02-16 15:40:58 +01:00
};
2012-02-28 13:09:12 +01:00
/*! \brief Resources used by About state. */
2012-02-18 06:26:58 +01:00
struct About {
2012-02-28 13:09:12 +01:00
ALLEGRO_BITMAP *fade_bitmap;
ALLEGRO_BITMAP *image;
ALLEGRO_BITMAP *text_bitmap;
ALLEGRO_BITMAP *letter;
2012-02-19 20:18:28 +01:00
ALLEGRO_SAMPLE *sample;
2012-02-22 13:38:56 +01:00
ALLEGRO_FONT *font;
float x;
2012-02-18 06:26:58 +01:00
};
2012-02-28 13:09:12 +01:00
/*! \brief Resources used by Map state. */
struct Map {
2012-02-28 13:09:12 +01:00
ALLEGRO_BITMAP *map;
ALLEGRO_BITMAP *background;
ALLEGRO_BITMAP *map_bg;
ALLEGRO_BITMAP *highlight;
ALLEGRO_BITMAP *arrow;
int selected;
int available;
2012-02-21 23:33:02 +01:00
float arrowpos;
2012-02-28 13:09:12 +01:00
ALLEGRO_SAMPLE *sample;
ALLEGRO_SAMPLE *click_sample;
};
2012-02-28 13:09:12 +01:00
/*! \brief Resources used by Intro state. */
2012-02-18 04:14:35 +01:00
struct Intro {
int position;
int page;
bool in_animation;
2012-02-28 13:09:12 +01:00
ALLEGRO_BITMAP *table;
ALLEGRO_BITMAP *table_bitmap;
ALLEGRO_FONT *font;
2012-02-19 20:18:28 +01:00
ALLEGRO_SAMPLE *sample;
2012-02-18 04:14:35 +01:00
};
2012-02-28 13:09:12 +01:00
/*! \brief Resources used by Game state. */
2012-02-16 15:40:58 +01:00
struct Game {
ALLEGRO_DISPLAY *display;
2012-02-28 13:09:12 +01:00
ALLEGRO_FONT *font;
ALLEGRO_FONT *font_console;
2012-02-16 15:40:58 +01:00
enum gamestate_enum gamestate;
enum gamestate_enum loadstate;
ALLEGRO_EVENT_QUEUE *event_queue;
ALLEGRO_TIMER *timer;
2012-02-17 13:25:06 +01:00
ALLEGRO_BITMAP *console;
2012-02-28 13:09:12 +01:00
bool showconsole;
bool fx;
bool music;
bool fullscreen;
bool debug;
int fps;
int width;
int height;
2012-02-16 15:40:58 +01:00
struct Menu menu;
struct Loading loading;
2012-02-18 04:14:35 +01:00
struct Intro intro;
2012-02-18 06:26:58 +01:00
struct About about;
struct Map map;
2012-02-22 12:43:14 +01:00
struct Level level;
2012-02-16 15:40:58 +01:00
};
2012-02-28 13:09:12 +01:00
/*! \brief Draws text with shadow.
*
* Draws given text two times: once with color (0,0,0,128) and 1px off in both x and y axis,
* and second time with actual given color and position.
*/
void al_draw_text_with_shadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *text);
2012-02-28 13:09:12 +01:00
/*! \brief Preloads gamestate set in game->loadstate. */
2012-02-16 15:40:58 +01:00
void PreloadGameState(struct Game *game);
2012-02-28 13:09:12 +01:00
/*! \brief Unloads gamestate set in game->gamestate. */
2012-02-16 15:40:58 +01:00
void UnloadGameState(struct Game *game);
2012-02-28 13:09:12 +01:00
/*! \brief Loads gamestate set in game->loadstate. */
2012-02-16 15:40:58 +01:00
void LoadGameState(struct Game *game);
2012-02-28 13:09:12 +01:00
/*! \brief Print some message on game console.
*
* Draws message on console bitmap, so it'll be displayed when calling DrawConsole.
* If game->debug is true, then it also prints given message on stdout.
* It needs to be called in printf style.
*/
void PrintConsole(struct Game *game, char* format, ...);
2012-02-28 13:09:12 +01:00
/*! \brief Draws console bitmap on screen. */
2012-02-17 13:25:06 +01:00
void DrawConsole(struct Game *game);
2012-02-16 15:40:58 +01:00
2012-02-26 00:47:41 +01:00
#endif