taisei/src/global.h

156 lines
2.6 KiB
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
*/
#ifndef GLOBAL_H
#define GLOBAL_H
#include <SDL/SDL.h>
#include "resource/audio.h"
#include "resource/shader.h"
#include "resource/font.h"
#include "resource/animation.h"
#include "menu/menu.h"
#include "player.h"
#include "projectile.h"
#include "enemy.h"
2011-04-29 10:26:37 +02:00
#include "item.h"
#include "boss.h"
#include "laser.h"
#include "dialog.h"
#include "list.h"
#include "config.h"
#include "fbo.h"
2011-12-25 08:18:03 +01:00
#include "vbo.h"
#include "resource/resource.h"
#include "replay.h"
2012-07-27 19:11:45 +02:00
#include "random.h"
#define FILE_PREFIX PREFIX "/share/taisei/"
2011-06-26 20:23:28 +02:00
#define CONFIG_FILE "config"
#undef min
#define min(a, b) ((a) < (b) ? (a) : (b))
2012-07-28 22:53:53 +02:00
enum {
// defaults
2012-07-20 21:24:12 +02:00
RESX = 800,
2012-07-28 22:53:53 +02:00
RESY = 600,
2012-07-20 21:24:12 +02:00
SCREEN_W = 800,
SCREEN_H = 600,
2012-07-20 21:24:12 +02:00
VIEWPORT_X = 40,
VIEWPORT_Y = 20,
VIEWPORT_W = 480,
VIEWPORT_H = 560,
POINT_OF_COLLECT = VIEWPORT_H/4,
ATTACK_START_DELAY = 40,
2011-07-05 15:20:19 +02:00
BOMB_RECOVERY = 250,
DEATHBOMB_TIME = 10,
2011-07-04 14:21:36 +02:00
DEATH_DELAY = 70,
PLR_MAXPOWER = 4,
PLR_START_LIVES = 2,
PLR_START_BOMBS = 3,
MAX_CONTINUES = 3,
ACTION_DESTROY,
EVENT_DEATH = -8999,
EVENT_BIRTH,
FPS = 60,
GAMEOVER_DEFEAT = 1,
GAMEOVER_WIN,
GAMEOVER_ABORT
};
typedef enum {
D_Easy = 1,
D_Normal,
D_Hard,
D_Lunatic
} Difficulty;
typedef struct {
int fpstime; // frame counter
2012-07-29 13:11:44 +02:00
int fps;
int show_fps;
2012-07-29 13:11:44 +02:00
double stagebg_fps;
} FPSCounter;
typedef struct {
Difficulty diff;
Player plr;
Projectile *projs;
Enemy *enemies;
2011-04-29 10:26:37 +02:00
Item *items;
Laser *lasers;
Projectile *particles;
int frames;
int lasttime; // frame limiter
int timer;
Boss *boss;
MenuData *menu;
Dialog *dialog;
RefArray refs; // for super extra OOP-tardness: references. the cool way.
2011-12-25 08:18:03 +01:00
int game_over;
int points;
FPSCounter fps;
2011-06-24 12:35:03 +02:00
int nostagebg; // I don't want the automatic stagebg handling to mess with the config, and I don't want that longass if in more than one place either.
Replay replay;
int replaymode;
2012-07-27 19:11:45 +02:00
RandomState rand_game;
RandomState rand_visual;
} Global;
extern Global global;
void init_global();
void game_over();
2011-12-29 09:37:17 +01:00
void frame_rate(int *lasttime);
void calc_fps(FPSCounter *fps);
2011-06-24 12:35:03 +02:00
void set_ortho();
2011-07-05 15:20:19 +02:00
void fade_out(float f);
2011-06-24 12:35:03 +02:00
void toggle_fullscreen();
void global_processevent(SDL_Event*);
void take_screenshot();
2012-07-29 13:11:44 +02:00
double approach(double v, double t, double d);
int strendswith(char *s, char *e);
char* difficulty_name(Difficulty diff);
void stralloc(char **dest, char *src);
2012-07-29 13:11:44 +02:00
// this is used by both player and replay code
enum {
EV_PRESS,
EV_RELEASE,
EV_OVER // replay-only
};
#define REPLAY_ASKSAVE (tconfig.intval[SAVE_RPY] == 2 && global.replay.active)
#endif