#pragma once #include #include #include #include #define __BSD_VISIBLE 1 #include //--- // Level strucutres //--- typedef enum { Shape_Square = 0, Shape_SmallBar = 2, Shape_MediumBar = 3, Shape_NormalBar = 4, Shape_LongBar = 5, Shape_HugeBar = 6, Shape_LongVertical = 7, } shape_t; typedef enum { Action_Normal = 0, Action_RotateLeft = 1, Action_RotateRight = 2, Action_Speed1 = 3, Action_FadeOut = 4, Action_OuterRotateLeft = 5, Action_OuterRotateRight = 6, Action_Slide = 7, Action_Speed2 = 8, Action_Speed3 = 9, } action_t; 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; } rectmeta_t; typedef struct { float tempo; const char *message; int block_count; rectmeta_t *blocks; } level_t; //--- // Game //--- #define PLAYER_X 60 #define PLAYER_R 40 #define PLAYER_SIZE 8 #define CORRIDOR_SIZE 150 #define RECT_SPEED 50 /* px/tempo */ typedef struct { float w, h; /* px */ float x, y; /* px */ float r; /* rad */ rectmeta_t const *meta; } rect_t; #define RECT_TABLE_SIZE 20 typedef struct game { /* Current level */ level_t const *level; /* List of rectangles (same amount as lv->block_count) */ rect_t *rects; int rect_count; /* Current player rotation */ float player_rota; /* 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; /* Forced rotation speed for level transitions and death rewind */ float forced_player_rota; } game_t; //--- // Rendering //--- void dcircle(int x, int y, int r, int color, bool fill); void dtriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color); void drectoid(rect_t const *r, int color); void render_player(int x, int y, float angle); //--- // 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); //--- // Physics //--- void player_position(float angle, float *x1, float *y1, float *x2, float *y2); bool player_collision(game_t const *game); bool rect_circle_collide(rect_t const *r, int cx, int cy, int cr); void rect_load(rect_t *r, rectmeta_t const *meta); void rect_physics(rect_t *r, rectmeta_t const *meta, float time); //--- // Levels //--- extern level_t level1, level2, level3, level4; extern level_t level5, level6, level7, level8; extern level_t level9, level10, level11, level12; extern level_t level13; //--- // Menu //--- /* Main menu, returns selected level or -1. */ int main_menu(void);