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
|
|
|
|
|
|
|
|
#include <SDL/SDL.h>
|
2011-06-13 18:48:36 +02:00
|
|
|
|
|
|
|
#include "resource/audio.h"
|
|
|
|
#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"
|
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-29 09:32:56 +02:00
|
|
|
#undef min
|
|
|
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
2012-07-29 10:58:46 +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,
|
2011-07-05 15:20:19 +02:00
|
|
|
BOMB_RECOVERY = 250,
|
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,
|
|
|
|
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,
|
2011-06-25 12:41:40 +02:00
|
|
|
GAMEOVER_ABORT
|
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-06-13 18:48:36 +02:00
|
|
|
MenuData *menu;
|
2011-05-08 13:48:25 +02:00
|
|
|
Dialog *dialog;
|
2011-04-08 18:59:03 +02:00
|
|
|
|
2011-05-13 19:03:02 +02:00
|
|
|
RefArray refs; // for super extra OOP-tardness: references. the cool way.
|
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-07-13 22:42:35 +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.
|
2012-07-14 19:46:03 +02:00
|
|
|
|
|
|
|
Replay replay;
|
|
|
|
int replaymode;
|
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;
|
|
|
|
|
|
|
|
void init_global();
|
2010-10-17 09:27:44 +02:00
|
|
|
void game_over();
|
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);
|
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
|
|
|
|
2011-07-02 16:06:10 +02:00
|
|
|
void toggle_fullscreen();
|
2011-07-02 18:36:08 +02:00
|
|
|
void global_processevent(SDL_Event*);
|
|
|
|
void take_screenshot();
|
2011-07-02 15:28:38 +02:00
|
|
|
|
2012-07-29 13:11:44 +02:00
|
|
|
double approach(double v, double t, double d);
|
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-07-29 13:11:44 +02:00
|
|
|
|
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,
|
|
|
|
EV_OVER // replay-only
|
2012-07-14 16:37:52 +02:00
|
|
|
};
|
|
|
|
|
2012-07-16 17:47:06 +02:00
|
|
|
#define REPLAY_ASKSAVE (tconfig.intval[SAVE_RPY] == 2 && global.replay.active)
|
|
|
|
|
2011-07-02 15:28:38 +02:00
|
|
|
#endif
|