Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MLOD Mini Projet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yoann Bordin
MLOD Mini Projet
Commits
76f29de8
Commit
76f29de8
authored
Oct 26, 2020
by
Yoann Bordin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added files
parent
69e47a5b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
0 deletions
+82
-0
tetris-main.c
tetris-main.c
+5
-0
tetris-struct.c
tetris-struct.c
+46
-0
tetris-struct.h
tetris-struct.h
+31
-0
No files found.
tetris-main.c
0 → 100644
View file @
76f29de8
#include "tetris-struct.h"
int
main
(){
}
\ No newline at end of file
tetris-struct.c
0 → 100644
View file @
76f29de8
#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
;
}
tetris-struct.h
0 → 100644
View file @
76f29de8
#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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment