#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_Speed = 3, Action_FadeOut = 4, Action_OuterRotateLeft = 5, Action_OuterRotateRIght = 6, Action_Slide = 7, } 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; int block_count; rectmeta_t *blocks; } level_t; //--- // Game //--- #define PLAYER_X 60 #define PLAYER_R 40 #define PLAYER_SIZE 8 #define CORRIDOR_SIZE 120 #define RECT_SPEED 60 /* 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 { int dead; float time; level_t *level; rectmeta_t const *current; rect_t table[RECT_TABLE_SIZE]; int cursor; float 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(float angle); //--- // 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; extern level_t level2; extern level_t level3; extern level_t level4; extern level_t level5; extern level_t level6; extern level_t level7;