2021-08-21 11:48:06 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gint/defs/types.h>
|
|
|
|
#include <stdint.h>
|
2021-08-21 12:10:53 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <gint/display.h>
|
|
|
|
|
|
|
|
#define __BSD_VISIBLE 1
|
2021-08-21 11:48:06 +02:00
|
|
|
#include <math.h>
|
|
|
|
|
2021-08-21 12:11:24 +02:00
|
|
|
//---
|
2022-01-16 11:29:46 +01:00
|
|
|
// Level structures
|
2021-08-21 12:11:24 +02:00
|
|
|
//---
|
|
|
|
|
|
|
|
typedef enum {
|
2021-08-21 16:31:19 +02:00
|
|
|
Shape_Square = 0,
|
|
|
|
Shape_SmallBar = 2,
|
|
|
|
Shape_MediumBar = 3,
|
|
|
|
Shape_NormalBar = 4,
|
|
|
|
Shape_LongBar = 5,
|
|
|
|
Shape_HugeBar = 6,
|
|
|
|
Shape_LongVertical = 7,
|
2021-08-21 12:11:24 +02:00
|
|
|
} shape_t;
|
|
|
|
|
|
|
|
typedef enum {
|
2021-08-21 14:00:35 +02:00
|
|
|
Action_Normal = 0,
|
|
|
|
Action_RotateLeft = 1,
|
|
|
|
Action_RotateRight = 2,
|
2021-08-21 22:52:08 +02:00
|
|
|
Action_Speed1 = 3,
|
2022-01-16 22:54:11 +01:00
|
|
|
Action__4 = 4,
|
2021-08-21 14:00:35 +02:00
|
|
|
Action_OuterRotateLeft = 5,
|
2021-08-21 22:09:32 +02:00
|
|
|
Action_OuterRotateRight = 6,
|
2021-08-21 14:00:35 +02:00
|
|
|
Action_Slide = 7,
|
2021-08-21 22:52:08 +02:00
|
|
|
Action_Speed2 = 8,
|
|
|
|
Action_Speed3 = 9,
|
2022-01-16 22:54:11 +01:00
|
|
|
Action_Slow = 10,
|
2021-08-21 12:11:24 +02:00
|
|
|
} action_t;
|
|
|
|
|
2022-01-16 22:54:11 +01:00
|
|
|
typedef enum {
|
|
|
|
Fadeout_None = 0,
|
|
|
|
Fadeout_1 = 1,
|
|
|
|
Fadeout_2 = 2,
|
|
|
|
Fadeout_3 = 3,
|
|
|
|
} fadeout_t;
|
|
|
|
|
2021-08-21 12:11:24 +02:00
|
|
|
typedef enum {
|
|
|
|
Position_Left = 0,
|
|
|
|
Position_Right = 1,
|
|
|
|
Position_Middle = 2
|
|
|
|
} position_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int time;
|
|
|
|
shape_t shape;
|
|
|
|
position_t position;
|
|
|
|
action_t action;
|
2022-01-16 22:54:11 +01:00
|
|
|
fadeout_t fadeout;
|
2021-08-21 12:11:24 +02:00
|
|
|
} rectmeta_t;
|
|
|
|
|
2021-08-21 14:00:35 +02:00
|
|
|
typedef struct {
|
2022-01-16 15:04:03 +01:00
|
|
|
float speed_factor;
|
2021-08-21 20:44:32 +02:00
|
|
|
const char *message;
|
2021-08-21 16:31:19 +02:00
|
|
|
int block_count;
|
2021-08-21 14:00:35 +02:00
|
|
|
rectmeta_t *blocks;
|
|
|
|
} level_t;
|
|
|
|
|
2021-08-21 23:46:47 +02:00
|
|
|
typedef struct {
|
|
|
|
char const *name;
|
|
|
|
int level_count;
|
|
|
|
level_t **levels;
|
|
|
|
} episode_t;
|
|
|
|
|
2021-08-21 14:00:35 +02:00
|
|
|
//---
|
|
|
|
// Game
|
|
|
|
//---
|
|
|
|
|
2021-08-21 16:31:19 +02:00
|
|
|
#define PLAYER_X 60
|
|
|
|
#define PLAYER_R 40
|
|
|
|
#define PLAYER_SIZE 8
|
2022-01-16 19:30:11 +01:00
|
|
|
#define CORRIDOR_SIZE 156
|
2021-08-21 16:31:19 +02:00
|
|
|
|
2021-08-21 16:45:08 +02:00
|
|
|
#define RECT_SPEED 50 /* px/tempo */
|
2021-08-21 14:49:01 +02:00
|
|
|
|
2021-08-21 14:00:35 +02:00
|
|
|
typedef struct {
|
|
|
|
float w, h; /* px */
|
2022-01-16 19:30:11 +01:00
|
|
|
float y_init; /* px */
|
2021-08-21 14:00:35 +02:00
|
|
|
float x, y; /* px */
|
2021-08-21 14:08:53 +02:00
|
|
|
float r; /* rad */
|
2022-01-16 22:54:11 +01:00
|
|
|
int opacity; /* 0..256 */
|
2021-08-21 16:31:19 +02:00
|
|
|
rectmeta_t const *meta;
|
2021-08-21 14:00:35 +02:00
|
|
|
} rect_t;
|
|
|
|
|
2021-08-21 14:49:01 +02:00
|
|
|
typedef struct game {
|
2021-08-21 21:48:47 +02:00
|
|
|
/* Current level */
|
2021-08-21 20:44:32 +02:00
|
|
|
level_t const *level;
|
2021-08-21 21:48:47 +02:00
|
|
|
/* List of rectangles (same amount as lv->block_count) */
|
2021-08-21 20:57:56 +02:00
|
|
|
rect_t *rects;
|
|
|
|
int rect_count;
|
2021-08-21 21:48:47 +02:00
|
|
|
|
|
|
|
/* Current player rotation */
|
2021-08-21 14:00:35 +02:00
|
|
|
float player_rota;
|
2021-08-21 21:48:47 +02:00
|
|
|
|
|
|
|
/* Current level time (determines the position of all objects) */
|
|
|
|
float time;
|
|
|
|
/* Time spent during the death freeze animation */
|
|
|
|
float time_dead;
|
|
|
|
/* Time spent during level transition */
|
|
|
|
float time_transition;
|
2021-08-22 00:41:42 +02:00
|
|
|
/* Time spent during episode transition */
|
|
|
|
float time_episode_transition;
|
2022-01-24 00:39:12 +01:00
|
|
|
/* Time sent during finale */
|
|
|
|
float time_finale;
|
2021-08-21 21:48:47 +02:00
|
|
|
|
|
|
|
/* Forced rotation speed for level transitions and death rewind */
|
2021-08-21 21:28:14 +02:00
|
|
|
float forced_player_rota;
|
2021-08-21 14:49:01 +02:00
|
|
|
} game_t;
|
2021-08-21 12:11:24 +02:00
|
|
|
|
2021-08-21 11:48:06 +02:00
|
|
|
//---
|
|
|
|
// Rendering
|
|
|
|
//---
|
|
|
|
|
2022-01-24 00:39:12 +01:00
|
|
|
void dcircle(int x, int y, int r, int color, bool fill, int rep1, int rep2);
|
2021-08-21 12:10:53 +02:00
|
|
|
|
2022-01-16 22:54:11 +01:00
|
|
|
void dtriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color,
|
|
|
|
int opacity);
|
2021-08-21 12:10:53 +02:00
|
|
|
|
2021-08-22 00:51:48 +02:00
|
|
|
void drectoid(rect_t const *r, float extra_size, int color);
|
2021-08-21 14:49:01 +02:00
|
|
|
|
2022-01-24 00:39:12 +01:00
|
|
|
void render_player(int x, int y, float angle, int r, float opacity);
|
|
|
|
|
|
|
|
void render_glow(int x, int y, int r1, int r2, int c1, int c2, float angle,
|
|
|
|
float opacity);
|
|
|
|
|
|
|
|
void radial_fadeout(int x, int y, int r1, int r2, int c);
|
2021-08-21 14:49:01 +02:00
|
|
|
|
2021-08-21 19:10:29 +02:00
|
|
|
//---
|
|
|
|
// Duet Text
|
|
|
|
//---
|
|
|
|
|
|
|
|
/* (x,y) is screen as usual, but align is relative to rotated text */
|
|
|
|
void duet_text_opt(int x, int y, int fg, int bg, int halign, int valign,
|
|
|
|
char const *str, int size);
|
|
|
|
|
2021-08-21 14:49:01 +02:00
|
|
|
//---
|
|
|
|
// Physics
|
|
|
|
//---
|
|
|
|
|
|
|
|
void player_position(float angle,
|
2022-01-24 00:39:12 +01:00
|
|
|
float *x1, float *y1, float *x2, float *y2, int r);
|
2021-08-21 14:49:01 +02:00
|
|
|
|
|
|
|
bool player_collision(game_t const *game);
|
2021-08-21 16:31:19 +02:00
|
|
|
|
2021-08-21 14:49:01 +02:00
|
|
|
bool rect_circle_collide(rect_t const *r, int cx, int cy, int cr);
|
2021-08-21 16:31:19 +02:00
|
|
|
|
|
|
|
void rect_load(rect_t *r, rectmeta_t const *meta);
|
|
|
|
|
|
|
|
void rect_physics(rect_t *r, rectmeta_t const *meta, float time);
|
|
|
|
|
|
|
|
//---
|
|
|
|
// Levels
|
|
|
|
//---
|
|
|
|
|
2022-01-16 19:30:11 +01:00
|
|
|
extern level_t level1_1, level1_2, level1_3, level1_4, level1_5;
|
|
|
|
extern level_t level2_1, level2_2, level2_3, level2_4, level2_5, level2_6;
|
|
|
|
extern level_t level3_1, level3_2, level3_3, level3_4, level3_5;
|
|
|
|
extern level_t level4_1, level4_2, level4_3, level4_4, level4_5, level4_6;
|
|
|
|
extern level_t level5_1, level5_2, level5_3, level5_4, level5_5, level5_6;
|
|
|
|
extern level_t level6_1, level6_2, level6_3, level6_4, level6_5, level6_6;
|
2022-01-16 21:00:19 +01:00
|
|
|
extern level_t level7_1, level7_2, level7_3, level7_4, level7_5, level7_6;
|
2022-01-16 22:54:11 +01:00
|
|
|
extern level_t level8_1, level8_2, level8_3, level8_4, level8_5, level8_6,
|
|
|
|
level8_7, level8_8, level8_9;
|
2021-08-21 22:32:22 +02:00
|
|
|
|
2021-08-21 23:46:47 +02:00
|
|
|
extern episode_t episodes[];
|
|
|
|
extern int episode_count;
|
|
|
|
|
2021-08-21 22:32:22 +02:00
|
|
|
//---
|
|
|
|
// Menu
|
|
|
|
//---
|
|
|
|
|
2021-08-21 23:46:47 +02:00
|
|
|
/* Main menu, sets selected level */
|
|
|
|
int main_menu(int *episode, int *level);
|