taisei/src/global.h

171 lines
2.8 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
2017-02-04 03:56:40 +01:00
#include <SDL.h>
#include "resource/audio.h"
2017-01-24 14:40:57 +01:00
#include "resource/bgm.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"
2012-08-13 17:50:28 +02:00
#include "events.h"
#define FILE_PREFIX PREFIX "/share/taisei/"
2011-06-26 20:23:28 +02:00
#define CONFIG_FILE "config"
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,
BOMB_RECOVERY = 300,
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,
2012-08-08 19:09:04 +02:00
MAX_CONTINUES = 3,
ACTION_DESTROY,
EVENT_DEATH = -8999,
EVENT_BIRTH,
FPS = 60,
GAMEOVER_DEFEAT = 1,
GAMEOVER_WIN,
2012-08-04 06:37:59 +02:00
GAMEOVER_ABORT,
2012-08-16 15:50:28 +02:00
GAMEOVER_REWATCH,
GAMEOVER_RESTART
};
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;
Dialog *dialog;
2012-08-03 17:06:25 +02:00
RefArray refs;
2011-12-25 08:18:03 +01:00
int game_over;
int points;
FPSCounter fps;
2011-06-24 12:35:03 +02:00
2012-08-03 17:06:25 +02:00
int nostagebg;
Replay replay;
int replaymode;
2012-07-27 19:11:45 +02:00
2012-08-01 17:32:11 +02:00
float shake_view;
2012-07-27 19:11:45 +02:00
RandomState rand_game;
RandomState rand_visual;
} Global;
extern Global global;
void print_state_checksum(void);
2012-08-07 21:27:32 +02:00
void init_global(void);
2011-12-29 09:37:17 +01:00
void frame_rate(int *lasttime);
void calc_fps(FPSCounter *fps);
void set_ortho(void);
void colorfill(float r, float g, float b, float a);
2011-07-05 15:20:19 +02:00
void fade_out(float f);
void take_screenshot(void);
2012-08-03 16:57:29 +02:00
// needed for mingw compatibility:
#undef min
#undef max
// NOTE: do NOT convert these to macros please.
// max(frand(), 0.5);
// min(huge_costly_expression, another_huge_costly_expression)
2012-07-18 19:19:14 +02:00
double min(double, double);
double max(double, double);
2012-08-05 03:36:55 +02:00
double clamp(double, double, double);
2012-07-29 13:11:44 +02:00
double approach(double v, double t, double d);
double psin(double);
int strendswith(char *s, char *e);
char* difficulty_name(Difficulty diff);
void stralloc(char **dest, char *src);
int gamekeypressed(int key);
2012-07-29 13:11:44 +02:00
2012-08-15 16:36:39 +02:00
#define SIGN(x) ((x > 0) - (x < 0))
// this is used by both player and replay code
enum {
EV_PRESS,
EV_RELEASE,
2012-08-15 16:36:39 +02:00
EV_OVER, // replay-only
EV_AXIS_LR,
EV_AXIS_UD,
2017-02-05 03:58:27 +01:00
EV_CHECK_DESYNC, // replay-only
};
#endif