mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 14:05:45 +01:00
use correct 8 bit colourspace instead of including alpha
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "../main.h"
|
||||
#include "../window/colour.h"
|
||||
#include "../window/colour8.h"
|
||||
#include "./tetromino/shapes.h"
|
||||
#include "tetromino/placing.h"
|
||||
|
||||
@@ -39,7 +39,7 @@ void game_init(GameData* const game_data) {
|
||||
|
||||
// allocate size for each row
|
||||
for (int8_t i = 0; i < ROWS; i++) {
|
||||
game_data->rows[i] = calloc(COLUMNS, sizeof(Colour));
|
||||
game_data->rows[i] = calloc(COLUMNS, sizeof(Colour8));
|
||||
// game_data->rows[i][0] = (Colour){(uint8_t)((((i + 1) ^ ((i + 1) >> 3)) * 0x27) & 0xFF)}; // for debugging
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../window/colour.h"
|
||||
#include "../window/colour8.h"
|
||||
#include "tetromino/shapes.h"
|
||||
|
||||
// stores the data used in the game
|
||||
#define COLUMNS ((int8_t)10)
|
||||
#define ROWS ((int8_t)(COLUMNS * 2))
|
||||
|
||||
typedef const Colour* CRow;
|
||||
typedef Colour* Row;
|
||||
typedef const Colour8* CRow;
|
||||
typedef Colour8* Row;
|
||||
|
||||
typedef struct {
|
||||
Row rows[ROWS];
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../../window/colour.h"
|
||||
#include "../../window/colour8.h"
|
||||
#include "../game.h"
|
||||
#include "shapes.h"
|
||||
|
||||
|
||||
static bool is_filled(CRow row) {
|
||||
for (int8_t x = 0; x < COLUMNS; x++) {
|
||||
if (row[x].packed == NONE) {
|
||||
if (row[x].packed == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ static void clear_rows(Row* rows) {
|
||||
// sets a shape to the screen
|
||||
static void set_shape_i(Row* row, const ShapeId id, const int8_t pos_x) {
|
||||
const Shape shape = shape_from_id(id);
|
||||
const Colour colour = colour_from_id(id);
|
||||
const Colour8 colour = colour_from_id(id);
|
||||
for (int8_t y = 0; y < SHAPE_HEIGHT; y++) {
|
||||
ShapeRow shape_row = shape_get_row(shape, y);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "shapes.h"
|
||||
|
||||
#include "../../window/colour.h"
|
||||
#include "../../window/colour8.h"
|
||||
|
||||
/* 0 1 2 3 */
|
||||
#define SHAPE_O ((Shape)0x0660) // 0000 0110 0110 0000 the O tetromino with no rotation
|
||||
@@ -53,7 +53,7 @@ Shape shape_from_id(ShapeId id) {
|
||||
return shapes[id & 7][id >> 3];
|
||||
}
|
||||
|
||||
Colour colour_from_id(ShapeId id) {
|
||||
Colour8 colour_from_id(ShapeId id) {
|
||||
switch (id & 7) {
|
||||
case TETROMINO_O: return COLOUR_YELLOW;
|
||||
case TETROMINO_I: return COLOUR_CYAN;
|
||||
@@ -62,6 +62,6 @@ Colour colour_from_id(ShapeId id) {
|
||||
case TETROMINO_T: return COLOUR_MAGENTA;
|
||||
case TETROMINO_L: return COLOUR_ORANGE;
|
||||
case TETROMINO_J: return COLOUR_BLUE;
|
||||
default: return COLOUR_NONE;
|
||||
default: return COLOUR_BLACK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../../window/colour.h"
|
||||
#include "../../window/colour8.h"
|
||||
|
||||
typedef uint16_t Shape;
|
||||
typedef uint8_t ShapeRow;
|
||||
@@ -36,4 +36,4 @@ static inline bool is_set(ShapeRow row, uint8_t index) {
|
||||
}
|
||||
|
||||
Shape shape_from_id(ShapeId id);
|
||||
Colour colour_from_id(ShapeId id);
|
||||
Colour8 colour_from_id(ShapeId id);
|
||||
|
||||
Reference in New Issue
Block a user