62 lines
1.4 KiB
C
62 lines
1.4 KiB
C
#include <stdlib.h>
|
|
#include <stdWullie.h>
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL_main.h>
|
|
|
|
// sdl flags
|
|
#define SDL_FLAGS (SDL_INIT_VIDEO | SDL_INIT_AUDIO)
|
|
|
|
// window shit
|
|
#define WindowTitle "Tetris"
|
|
#define width 800
|
|
#define height 800
|
|
|
|
|
|
typedef struct GameInit {
|
|
SDL_Window *window;
|
|
SDL_Renderer *renderer;
|
|
SDL_AudioStream *stream;
|
|
|
|
SDL_Event event;
|
|
bool isRunning;
|
|
|
|
|
|
} GameInit;
|
|
|
|
// blocks
|
|
#define squareSize 30
|
|
#define ColourSquare 255, 215, 0, 100
|
|
#define ColourRightL 255, 200, 46, 100
|
|
#define ColourLeftL 72, 93, 197, 100
|
|
#define ColourT 120, 37, 111, 100
|
|
#define ColourI 1, 237, 250, 100
|
|
#define ColourLeftZ 0, 255, 0, 100
|
|
#define ColourRightZ 234, 20, 28, 100
|
|
void renderBlockSquare(GameInit *game);
|
|
void renderBlockRightL(GameInit *game);
|
|
void renderBlockLeftL(GameInit *game);
|
|
void renderBlockT(GameInit *game);
|
|
void renderBlockI(GameInit *game);
|
|
void renderBlockLeftZ(GameInit *game);
|
|
void renderBlockRightZ(GameInit *game);
|
|
int generateNextBlock();
|
|
|
|
//sdl shit
|
|
void sdlGameInit(GameInit *game);
|
|
void sdlGameFree(GameInit **gameInit);
|
|
|
|
// player
|
|
#define playerCurrentBlock playerBlock[4]
|
|
#define GameFilledRows FilledRows[190]
|
|
void tetrisPlayerSwitch(GameInit *game);
|
|
|
|
// game shit
|
|
void gameLoop(GameInit *game);
|
|
void gameEventCheck(GameInit *game);
|
|
void gameDrawContext(GameInit *game);
|
|
void gameCreateContext(GameInit **gameInit);
|
|
void tetrisDrawGrid(GameInit *game);
|
|
void tetrisDrawBoxes(GameInit *game);
|
|
|