2010-10-12 10:55:23 +02:00
|
|
|
/*
|
2011-03-05 13:44:21 +01:00
|
|
|
* This software is licensed under the terms of the MIT-License
|
2011-03-17 21:13:11 +01:00
|
|
|
* See COPYING for further information.
|
2011-03-05 13:44:21 +01:00
|
|
|
* ---
|
|
|
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
2010-10-12 10:55:23 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GLOBAL_H
|
|
|
|
#define GLOBAL_H
|
|
|
|
|
2017-02-04 03:56:40 +01:00
|
|
|
#include <SDL.h>
|
2011-06-13 18:48:36 +02:00
|
|
|
|
|
|
|
#include "resource/audio.h"
|
2017-01-24 14:40:57 +01:00
|
|
|
#include "resource/bgm.h"
|
2011-06-13 18:48:36 +02:00
|
|
|
#include "resource/shader.h"
|
|
|
|
#include "resource/font.h"
|
|
|
|
#include "resource/animation.h"
|
|
|
|
|
|
|
|
#include "menu/menu.h"
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
#include "player.h"
|
|
|
|
#include "projectile.h"
|
2011-04-26 12:04:45 +02:00
|
|
|
#include "enemy.h"
|
2011-04-29 10:26:37 +02:00
|
|
|
#include "item.h"
|
2011-04-08 18:59:03 +02:00
|
|
|
#include "boss.h"
|
2011-04-24 15:39:17 +02:00
|
|
|
#include "laser.h"
|
2011-05-08 13:48:25 +02:00
|
|
|
#include "dialog.h"
|
2011-05-13 19:03:02 +02:00
|
|
|
#include "list.h"
|
2011-05-21 18:20:04 +02:00
|
|
|
#include "config.h"
|
2011-06-13 18:48:36 +02:00
|
|
|
#include "fbo.h"
|
2011-12-25 08:18:03 +01:00
|
|
|
#include "vbo.h"
|
2011-07-04 09:14:08 +02:00
|
|
|
#include "resource/resource.h"
|
2012-07-14 19:46:03 +02:00
|
|
|
#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"
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-05-21 18:20:04 +02:00
|
|
|
#define FILE_PREFIX PREFIX "/share/taisei/"
|
2011-06-26 20:23:28 +02:00
|
|
|
#define CONFIG_FILE "config"
|
2011-06-13 18:48:36 +02:00
|
|
|
|
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
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
SCREEN_W = 800,
|
|
|
|
SCREEN_H = 600,
|
2012-07-20 21:24:12 +02:00
|
|
|
|
2010-11-28 07:31:26 +01:00
|
|
|
VIEWPORT_X = 40,
|
|
|
|
VIEWPORT_Y = 20,
|
|
|
|
VIEWPORT_W = 480,
|
|
|
|
VIEWPORT_H = 560,
|
2010-10-18 14:40:15 +02:00
|
|
|
|
2011-03-19 09:11:05 +01:00
|
|
|
POINT_OF_COLLECT = VIEWPORT_H/4,
|
2011-05-09 13:42:02 +02:00
|
|
|
ATTACK_START_DELAY = 40,
|
2012-08-14 17:44:02 +02:00
|
|
|
BOMB_RECOVERY = 300,
|
2011-06-25 12:41:40 +02:00
|
|
|
DEATHBOMB_TIME = 10,
|
2011-07-04 14:21:36 +02:00
|
|
|
DEATH_DELAY = 70,
|
2011-07-02 12:45:32 +02:00
|
|
|
|
2011-06-29 17:01:03 +02:00
|
|
|
PLR_MAXPOWER = 4,
|
2011-07-02 12:45:32 +02:00
|
|
|
PLR_START_LIVES = 2,
|
|
|
|
PLR_START_BOMBS = 3,
|
2012-08-08 19:09:04 +02:00
|
|
|
MAX_CONTINUES = 3,
|
2011-03-19 09:11:05 +01:00
|
|
|
|
2011-05-13 19:03:02 +02:00
|
|
|
ACTION_DESTROY,
|
|
|
|
|
2011-04-26 12:04:45 +02:00
|
|
|
EVENT_DEATH = -8999,
|
|
|
|
EVENT_BIRTH,
|
|
|
|
|
2011-06-25 12:41:40 +02:00
|
|
|
FPS = 60,
|
|
|
|
|
|
|
|
GAMEOVER_DEFEAT = 1,
|
2012-01-06 21:52:55 +01:00
|
|
|
GAMEOVER_WIN,
|
2012-08-04 06:37:59 +02:00
|
|
|
GAMEOVER_ABORT,
|
2012-08-16 15:50:28 +02:00
|
|
|
GAMEOVER_REWATCH,
|
|
|
|
GAMEOVER_RESTART
|
2010-10-12 10:55:23 +02:00
|
|
|
};
|
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
typedef enum {
|
2011-11-06 16:17:46 +01:00
|
|
|
D_Easy = 1,
|
2011-06-13 18:48:36 +02:00
|
|
|
D_Normal,
|
|
|
|
D_Hard,
|
|
|
|
D_Lunatic
|
|
|
|
} Difficulty;
|
|
|
|
|
2010-10-18 14:40:15 +02:00
|
|
|
typedef struct {
|
2011-06-13 18:48:36 +02:00
|
|
|
int fpstime; // frame counter
|
2012-07-29 13:11:44 +02:00
|
|
|
int fps;
|
2011-06-13 18:48:36 +02:00
|
|
|
int show_fps;
|
2012-07-29 13:11:44 +02:00
|
|
|
double stagebg_fps;
|
2011-06-13 18:48:36 +02:00
|
|
|
} FPSCounter;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Difficulty diff;
|
2011-06-24 19:16:05 +02:00
|
|
|
Player plr;
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
Projectile *projs;
|
2011-04-26 12:04:45 +02:00
|
|
|
Enemy *enemies;
|
2011-04-29 10:26:37 +02:00
|
|
|
Item *items;
|
2011-04-24 15:39:17 +02:00
|
|
|
Laser *lasers;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-05-13 19:03:02 +02:00
|
|
|
Projectile *particles;
|
|
|
|
|
2011-03-05 13:44:21 +01:00
|
|
|
int frames;
|
2011-07-04 09:14:08 +02:00
|
|
|
int lasttime; // frame limiter
|
2011-05-08 13:48:25 +02:00
|
|
|
int timer;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-04-08 18:59:03 +02:00
|
|
|
Boss *boss;
|
2011-05-08 13:48:25 +02:00
|
|
|
Dialog *dialog;
|
2011-04-08 18:59:03 +02:00
|
|
|
|
2012-08-03 17:06:25 +02:00
|
|
|
RefArray refs;
|
2011-12-25 08:18:03 +01:00
|
|
|
|
2010-10-17 09:27:44 +02:00
|
|
|
int game_over;
|
2011-04-10 10:23:24 +02:00
|
|
|
int points;
|
2011-07-02 15:28:38 +02:00
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
FPSCounter fps;
|
2011-06-24 12:35:03 +02:00
|
|
|
|
2012-08-03 17:06:25 +02:00
|
|
|
int nostagebg;
|
2012-07-14 19:46:03 +02:00
|
|
|
|
|
|
|
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;
|
2010-10-12 10:55:23 +02:00
|
|
|
} Global;
|
|
|
|
|
|
|
|
extern Global global;
|
|
|
|
|
2012-08-10 22:08:51 +02:00
|
|
|
void print_state_checksum(void);
|
2012-08-07 21:27:32 +02:00
|
|
|
|
2012-08-10 22:08:51 +02:00
|
|
|
void init_global(void);
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-12-29 09:37:17 +01:00
|
|
|
void frame_rate(int *lasttime);
|
2011-06-26 16:10:13 +02:00
|
|
|
void calc_fps(FPSCounter *fps);
|
2012-08-10 22:08:51 +02:00
|
|
|
void set_ortho(void);
|
2012-08-06 06:17:51 +02:00
|
|
|
void colorfill(float r, float g, float b, float a);
|
2011-07-05 15:20:19 +02:00
|
|
|
void fade_out(float f);
|
2012-08-10 22:08:51 +02:00
|
|
|
void take_screenshot(void);
|
2012-07-29 12:31:04 +02:00
|
|
|
|
2012-08-03 16:57:29 +02:00
|
|
|
// needed for mingw compatibility:
|
|
|
|
#undef min
|
|
|
|
#undef max
|
|
|
|
|
2012-07-29 12:31:04 +02:00
|
|
|
// 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);
|
2012-08-10 22:08:51 +02:00
|
|
|
double psin(double);
|
2012-07-29 22:39:52 +02:00
|
|
|
int strendswith(char *s, char *e);
|
|
|
|
char* difficulty_name(Difficulty diff);
|
|
|
|
void stralloc(char **dest, char *src);
|
2012-08-17 20:58:23 +02:00
|
|
|
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))
|
|
|
|
|
2012-07-14 16:37:52 +02:00
|
|
|
// this is used by both player and replay code
|
|
|
|
enum {
|
|
|
|
EV_PRESS,
|
2012-07-14 19:46:03 +02:00
|
|
|
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
|
2012-07-14 16:37:52 +02:00
|
|
|
};
|
|
|
|
|
2011-07-02 15:28:38 +02:00
|
|
|
#endif
|