mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 05:55:46 +01:00
rename more typedefs to lowercase
This commit is contained in:
@@ -73,7 +73,7 @@ void game_update(game_data* const dat, uint8_t const* const keys) {
|
||||
if (keys[SDL_SCANCODE_ESCAPE])
|
||||
stop();
|
||||
|
||||
InputData move = MOVE_NONE; // contains the move data
|
||||
input_data move = MOVE_NONE; // contains the move data
|
||||
uint32_t ctime = SDL_GetTicks();
|
||||
|
||||
if (ctime > dat->timer_update) {
|
||||
@@ -87,7 +87,7 @@ void game_update(game_data* const dat, uint8_t const* const keys) {
|
||||
}
|
||||
|
||||
if (ctime > dat->timer_input) {
|
||||
InputData umove = MOVE_NONE;
|
||||
input_data umove = MOVE_NONE;
|
||||
|
||||
// get the input data and apply it to move
|
||||
if (keys[SDL_SCANCODE_LEFT] || keys[SDL_SCANCODE_A]) umove |= MOVE_LEFT;
|
||||
|
||||
@@ -59,10 +59,10 @@ static void clear_rows(row* const rows, uint16_t* const score) {
|
||||
|
||||
// sets a shape to the screen
|
||||
static void set_shape_i(row const* const row, shape_id const id, int8_t const pos_x) {
|
||||
Shape const shape = shape_from_id(id);
|
||||
shape const shape = shape_from_id(id);
|
||||
colour8 const colour = colour_from_id(id);
|
||||
for (int8_t y = 0; y < SHAPE_HEIGHT; y++) {
|
||||
ShapeRow const shape_row = shape_get_row(shape, y);
|
||||
shape_row const shape_row = shape_get_row(shape, y);
|
||||
|
||||
if (shape_row == 0)
|
||||
continue;
|
||||
@@ -78,10 +78,10 @@ static inline void set_shape(row const* const row, shape_id const id, int8_t con
|
||||
}
|
||||
|
||||
static bool shape_intersects(row const* const rows, shape_id const id, int8_t const x, int8_t const y) {
|
||||
Shape const shape = shape_from_id(id);
|
||||
shape const shape = shape_from_id(id);
|
||||
|
||||
for (int8_t y0 = 0; y0 < SHAPE_HEIGHT; y0++) {
|
||||
ShapeRow const shape_row = shape_get_row(shape, y0); // get the shape row
|
||||
shape_row const shape_row = shape_get_row(shape, y0); // get the shape row
|
||||
if (shape_row == 0) continue; // if the row doesn't contain data; continue
|
||||
|
||||
for (int8_t x0 = 0; x0 < SHAPE_WIDTH; x0++) {
|
||||
@@ -101,7 +101,7 @@ static inline shape_id rotate_id(shape_id const id, int const dir) {
|
||||
return (id + dir) & 31;
|
||||
}
|
||||
|
||||
void place_update(game_data* const game_data, InputData const move) {
|
||||
void place_update(game_data* const game_data, input_data const move) {
|
||||
// store the current index and ID, only changes when placed (which yields no movement) and rotation (which occurs last)
|
||||
uint8_t const curr_idx = game_data->curr_idx;
|
||||
shape_id const curr_id = game_data->nxt[curr_idx];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "../game.h"
|
||||
|
||||
typedef uint8_t InputData;
|
||||
typedef uint8_t input_data;
|
||||
enum {
|
||||
MOVE_NONE = 0,
|
||||
MOVE_LEFT = 1,
|
||||
@@ -15,7 +15,7 @@ enum {
|
||||
MOVE_ROTRIGHT = 16,
|
||||
};
|
||||
|
||||
void place_update(game_data* game_data, InputData move);
|
||||
void place_update(game_data* game_data, input_data move);
|
||||
|
||||
#ifdef DEBUG
|
||||
void dbg_set_all(game_data* game_data);
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
#define SHAPE_J_180 ((Shape)0x6440) // 0110 0100 0100 0000 the J tetromino with a 180° rotation
|
||||
#define SHAPE_J_270 ((Shape)0x0E20) // 0000 1110 0010 0000 the J tetromino with a 270° rotation
|
||||
|
||||
Shape shape_from_id(shape_id const id) {
|
||||
shape shape_from_id(shape_id const id) {
|
||||
// clang-format off
|
||||
static Shape const shapes[TETROMINO_COUNT][4] = {
|
||||
static shape const shapes[TETROMINO_COUNT][4] = {
|
||||
// 0° 90° 180° 170°
|
||||
{SHAPE_O, SHAPE_O, SHAPE_O, SHAPE_O},
|
||||
{SHAPE_I, SHAPE_I_90, SHAPE_I_180, SHAPE_I_270},
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "../../window/colour8.h"
|
||||
|
||||
typedef uint16_t Shape;
|
||||
typedef uint8_t ShapeRow;
|
||||
typedef uint16_t shape;
|
||||
typedef uint8_t shape_row;
|
||||
|
||||
typedef uint8_t shape_id;
|
||||
enum {
|
||||
@@ -27,13 +27,13 @@ enum {
|
||||
|
||||
|
||||
|
||||
static inline ShapeRow shape_get_row(Shape const shape, uint8_t const index) {
|
||||
static inline shape_row shape_get_row(shape const shape, uint8_t const index) {
|
||||
return shape >> (((SHAPE_HEIGHT - 1) - index) * SHAPE_WIDTH) & 0xF;
|
||||
}
|
||||
|
||||
static inline bool is_set(ShapeRow const row, uint8_t const index) {
|
||||
static inline bool is_set(shape_row const row, uint8_t const index) {
|
||||
return (row >> ((SHAPE_WIDTH - 1) - index) & 1) != 0;
|
||||
}
|
||||
|
||||
Shape shape_from_id(shape_id id);
|
||||
shape shape_from_id(shape_id id);
|
||||
colour8 colour_from_id(shape_id id);
|
||||
|
||||
@@ -75,11 +75,11 @@ static inline void set_colour(SDL_Renderer* const renderer, colour8 const c) {
|
||||
|
||||
// draws a shape at the specified position
|
||||
static void draw_shape(SDL_Renderer* const renderer, shape_id const id, int8_t const pos_x, int8_t const pos_y) {
|
||||
Shape const shape = shape_from_id(id);
|
||||
shape const shape = shape_from_id(id);
|
||||
set_colour(renderer, colour_from_id(id));
|
||||
|
||||
for (int8_t y = 0; y < SHAPE_HEIGHT; y++) {
|
||||
ShapeRow const shape_row = shape_get_row(shape, y);
|
||||
shape_row const shape_row = shape_get_row(shape, y);
|
||||
|
||||
if (shape_row == 0)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user