Commit 76f29de8 authored by Yoann Bordin's avatar Yoann Bordin

Added files

parent 69e47a5b
#include "tetris-struct.h"
int main(){
}
\ No newline at end of file
#include "tetris-struct.h"
#include <stdlib.h>
Grid gridInit(){
Grid g;
g.matrix = calloc(g.width, sizeof(Square*));
for(int i = 0; i < g.width; i++){
g.matrix[i] = calloc(g.height, sizeof(Square));
}
g.matrix = squareMatrixInit(g.matrix, g.width, g.height);
return g;
}
Square squareInit(){
Square sq;
sq.isFilled = false;
return sq;
}
Square** squareMatrixInit(Square** matrix, int width, int height){
for(int i = 0; i < width; i++){
for(int j = 0; j < height; j++){
matrix[i][j] = squareInit();
}
}
return matrix;
}
Piece pieceInit(){
Piece p;
p.matrix = calloc(p.size, sizeof(Square*));
for(int i = 0; i < p.size; i++){
p.matrix[i] = calloc(p.size, sizeof(Square));
}
p.matrix = squareMatrixInit(p.matrix, p.size, p.size);
return p;
}
#include <stdbool.h>
typedef struct Square{
int size;
bool isFilled;
} Square;
typedef struct Grid
{
int height = 20;
int width = 10;
Square** matrix;
} Grid;
typedef struct Piece
{
int size = 4;
Square** matrix;
} Piece;
Grid gridInit();
Square squareInit();
Square** squareMatrixInit(Square** matrix, int width, int height);
Piece pieceInit();
void down();
void move();
void rotate();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment