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
13a4fb8b
Commit
13a4fb8b
authored
4 years ago
by
Yoann Bordin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixes
parent
95aa3d4d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
10 deletions
+53
-10
tetris-graph.h
tetris-graph.h
+2
-2
tetris-main.c
tetris-main.c
+12
-0
tetris-main.exe
tetris-main.exe
+0
-0
tetris-struct.c
tetris-struct.c
+37
-7
tetris-struct.h
tetris-struct.h
+2
-1
No files found.
tetris-graph.h
View file @
13a4fb8b
#include "tetris-struct.h"
#define SCREEN_WIDTH
128
0
#define SCREEN_HEIGHT 7
2
0
#define SCREEN_WIDTH
70
0
#define SCREEN_HEIGHT 7
0
0
#define BORDER_GAP 20
#define SQUARE_SIZE 30
...
...
This diff is collapsed.
Click to expand it.
tetris-main.c
View file @
13a4fb8b
...
...
@@ -46,6 +46,12 @@ int main(void){
while
(
rotateCollideRight
(
p
,
false
)){
movePieceHztl
(
p
,
-
1
);
}
while
(
rotateCollideTop
(
p
,
false
)){
movePieceVert
(
p
,
1
);
}
while
(
rotateCollideBottom
(
p
,
false
)){
movePieceVert
(
p
,
-
1
);
}
while
(
rotateCollideGrid
(
grid
,
p
,
false
)){
movePieceVert
(
p
,
-
1
);
}
...
...
@@ -60,6 +66,12 @@ int main(void){
while
(
rotateCollideRight
(
p
,
true
)){
movePieceHztl
(
p
,
-
1
);
}
while
(
rotateCollideTop
(
p
,
true
)){
movePieceVert
(
p
,
1
);
}
while
(
rotateCollideBottom
(
p
,
true
)){
movePieceVert
(
p
,
-
1
);
}
while
(
rotateCollideGrid
(
grid
,
p
,
true
)){
movePieceVert
(
p
,
-
1
);
}
...
...
This diff is collapsed.
Click to expand it.
tetris-main.exe
View file @
13a4fb8b
No preview for this file type
This diff is collapsed.
Click to expand it.
tetris-struct.c
View file @
13a4fb8b
...
...
@@ -221,7 +221,7 @@ bool rotateCollideRight(Piece p, bool rotation){
newPosY
=
refY
+
posX
-
refX
;
}
if
(
newPosY
<
0
){
if
(
newPosY
>=
GRID_WIDTH
){
return
true
;
}
}
...
...
@@ -231,19 +231,49 @@ bool rotateCollideRight(Piece p, bool rotation){
bool
rotateCollideTop
(
Piece
p
,
bool
rotation
){
int
refX
=
p
.
squares
[
1
]
->
posX
;
int
refY
=
p
.
squares
[
1
]
->
posY
;
int
newPosX
,
newPosY
;
int
posX
,
posY
;
for
(
int
i
=
0
;
i
<
p
.
size
;
i
++
){
int
posY
=
p
.
squares
[
i
]
->
posY
;
int
newPosX
;
posX
=
p
.
squares
[
i
]
->
posX
;
posY
=
p
.
squares
[
i
]
->
posY
;
if
(
rotation
){
newPosX
=
refX
+
posY
-
refY
;
if
(
rotation
){
newPosX
=
refX
-
posY
+
refY
;
newPosY
=
refY
+
posX
-
refX
;
}
else
{
newPosX
=
refX
+
posY
-
refY
;
newPosY
=
refY
-
posX
+
refX
;
}
if
(
newPosY
<
0
){
return
true
;
}
}
return
false
;
}
bool
rotateCollideBottom
(
Piece
p
,
bool
rotation
){
int
refX
=
p
.
squares
[
1
]
->
posX
;
int
refY
=
p
.
squares
[
1
]
->
posY
;
int
newPosX
,
newPosY
;
int
posX
,
posY
;
for
(
int
i
=
0
;
i
<
p
.
size
;
i
++
){
posX
=
p
.
squares
[
i
]
->
posX
;
posY
=
p
.
squares
[
i
]
->
posY
;
if
(
rotation
){
newPosX
=
refX
-
posY
+
refY
;
newPosY
=
refY
+
posX
-
refX
;
}
else
{
newPosX
=
refX
+
posY
-
refY
;
newPosY
=
refY
-
posX
+
refX
;
}
if
(
newPosX
<
0
){
if
(
newPosY
>=
GRID_HEIGHT
){
return
true
;
}
}
...
...
@@ -268,7 +298,7 @@ bool rotateCollideGrid(Grid g, Piece p, bool rotation){
newPosY
=
refY
-
posX
+
refX
;
}
if
(
newPosX
<
0
&&
newPosX
>=
GRID_WIDTH
&&
g
.
grid
[
newPosX
][
newPosY
]
!=
NULL
){
if
(
g
.
grid
[
newPosX
][
newPosY
]
!=
NULL
){
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tetris-struct.h
View file @
13a4fb8b
...
...
@@ -64,7 +64,8 @@ void movePieceHztl(Piece p, int shift);
// Bool verifications for rotating
bool
rotateCollideLeft
(
Piece
p
,
bool
rotation
);
bool
rotateCollideRight
(
Piece
p
,
bool
rotation
);
bool
rotateCollideTop
(
Piece
p
,
bool
rotation
);
// To debug
bool
rotateCollideTop
(
Piece
p
,
bool
rotation
);
bool
rotateCollideBottom
(
Piece
p
,
bool
rotation
);
bool
rotateCollideGrid
(
Grid
g
,
Piece
p
,
bool
rotation
);
// Rotating functions
...
...
This diff is collapsed.
Click to expand it.
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