Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Mini_Projet_C
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
MESLIN Léa
Mini_Projet_C
Commits
5158a7a6
Commit
5158a7a6
authored
Oct 30, 2020
by
MESLIN Léa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update arkanoid_lea_meslin.c
parent
07a6ea8e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
20 deletions
+68
-20
arkanoid_lea_meslin.c
arkanoid_lea_meslin.c
+68
-20
No files found.
arkanoid_lea_meslin.c
View file @
5158a7a6
...
...
@@ -14,7 +14,7 @@
// Some Defines
//----------------------------------------------------------------------------------
#define PLAYER_MAX_LIFE 5
#define LINES_OF_BRICKS
5
#define LINES_OF_BRICKS
6
#define BRICKS_PER_LINE 20
//----------------------------------------------------------------------------------
...
...
@@ -45,10 +45,11 @@ typedef struct Brick {
// Global Variables Declaration
//------------------------------------------------------------------------------------
static
const
int
screenWidth
=
800
;
static
const
int
screenHeight
=
4
50
;
static
const
int
screenHeight
=
5
50
;
static
int
score
=
0
;
static
int
highScore
=
-
50
;
static
int
choixTheme
=
0
;
static
bool
gameOver
=
false
;
static
bool
pause
=
false
;
...
...
@@ -135,6 +136,15 @@ void InitGame(void)
{
brick
[
i
][
j
].
position
=
(
Vector2
){
j
*
brickSize
.
x
+
brickSize
.
x
/
2
,
i
*
brickSize
.
y
+
initialDownPosition
};
brick
[
i
][
j
].
active
=
true
;
brick
[
i
][
j
].
couleur
=
0
;
//Valeur par défaut
}
}
choixTheme
=
GetRandomValue
(
0
,
1
);
if
(
choixTheme
==
0
){
for
(
int
i
=
0
;
i
<
LINES_OF_BRICKS
;
i
++
)
{
for
(
int
j
=
0
;
j
<
BRICKS_PER_LINE
;
j
++
)
{
int
random
=
GetRandomValue
(
0
,
3
);
switch
(
random
){
case
0
:
{
brick
[
i
][
j
].
couleur
=
0
;}
break
;
...
...
@@ -144,9 +154,46 @@ void InitGame(void)
}
}
}
}
else
{
//Cas coeur
for
(
int
i
=
0
;
i
<
6
;
i
++
){
for
(
int
j
=
2
;
j
<
9
;
j
++
){
brick
[
i
][
j
].
couleur
=
2
;
brick
[
i
][
j
+
9
].
couleur
=
2
;
}
}
brick
[
4
][
5
].
couleur
=
3
;
brick
[
4
][
14
].
couleur
=
3
;
brick
[
3
][
4
].
couleur
=
3
;
brick
[
3
][
13
].
couleur
=
3
;
brick
[
3
][
6
].
couleur
=
3
;
brick
[
3
][
15
].
couleur
=
3
;
brick
[
2
][
3
].
couleur
=
3
;
brick
[
2
][
12
].
couleur
=
3
;
brick
[
2
][
5
].
couleur
=
3
;
brick
[
2
][
14
].
couleur
=
3
;
brick
[
2
][
7
].
couleur
=
3
;
brick
[
2
][
16
].
couleur
=
3
;
brick
[
1
][
3
].
couleur
=
3
;
brick
[
1
][
12
].
couleur
=
3
;
brick
[
1
][
4
].
couleur
=
3
;
brick
[
1
][
13
].
couleur
=
3
;
brick
[
1
][
6
].
couleur
=
3
;
brick
[
1
][
15
].
couleur
=
3
;
brick
[
1
][
7
].
couleur
=
3
;
brick
[
1
][
16
].
couleur
=
3
;
brick
[
2
][
6
].
couleur
=
1
;
brick
[
2
][
15
].
couleur
=
1
;
brick
[
2
][
4
].
couleur
=
1
;
brick
[
2
][
13
].
couleur
=
1
;
brick
[
3
][
5
].
couleur
=
1
;
brick
[
3
][
14
].
couleur
=
1
;
}
}
void
briqueCouleur
Roug
e
(
int
i
,
int
j
){
void
briqueCouleur
Bleu
e
(
int
i
,
int
j
){
if
((
brick
[
i
][
j
].
couleur
==
1
)){
int
k
=
i
;
int
l
=
j
;
...
...
@@ -179,6 +226,7 @@ void briqueCouleurRouge(int i, int j){
brick
[
k
][
l
-
1
].
active
=
false
;
brick
[
k
][
l
+
1
].
active
=
false
;
}
score
+=
4
;
}
}
...
...
@@ -189,7 +237,7 @@ void briqueCouleurNoire(int i, int j){
}
}
void
briqueCouleurV
er
te
(
int
i
,
int
j
){
void
briqueCouleurV
iolet
te
(
int
i
,
int
j
){
if
((
brick
[
i
][
j
].
couleur
==
3
)){
ball
.
position
.
y
=
screenHeight
*
1
/
8
;
ball
.
speed
.
x
+=
-
1
/
2
;
...
...
@@ -273,9 +321,9 @@ void UpdateGame(void)
{
brick
[
i
][
j
].
active
=
false
;
ball
.
speed
.
y
*=
-
1
;
briqueCouleur
Roug
e
(
i
,
j
);
briqueCouleur
Bleu
e
(
i
,
j
);
briqueCouleurNoire
(
i
,
j
);
briqueCouleurV
er
te
(
i
,
j
);
briqueCouleurV
iolet
te
(
i
,
j
);
score
+=
1
;
}
// Hit above
...
...
@@ -285,9 +333,9 @@ void UpdateGame(void)
{
brick
[
i
][
j
].
active
=
false
;
ball
.
speed
.
y
*=
-
1
;
briqueCouleur
Roug
e
(
i
,
j
);
briqueCouleur
Bleu
e
(
i
,
j
);
briqueCouleurNoire
(
i
,
j
);
briqueCouleurV
er
te
(
i
,
j
);
briqueCouleurV
iolet
te
(
i
,
j
);
score
+=
1
;
}
// Hit left
...
...
@@ -297,9 +345,9 @@ void UpdateGame(void)
{
brick
[
i
][
j
].
active
=
false
;
ball
.
speed
.
x
*=
-
1
;
briqueCouleur
Roug
e
(
i
,
j
);
briqueCouleur
Bleu
e
(
i
,
j
);
briqueCouleurNoire
(
i
,
j
);
briqueCouleurV
er
te
(
i
,
j
);
briqueCouleurV
iolet
te
(
i
,
j
);
score
+=
1
;
}
// Hit right
...
...
@@ -309,9 +357,9 @@ void UpdateGame(void)
{
brick
[
i
][
j
].
active
=
false
;
ball
.
speed
.
x
*=
-
1
;
briqueCouleur
Roug
e
(
i
,
j
);
briqueCouleur
Bleu
e
(
i
,
j
);
briqueCouleurNoire
(
i
,
j
);
briqueCouleurV
er
te
(
i
,
j
);
briqueCouleurV
iolet
te
(
i
,
j
);
score
+=
1
;
}
}
...
...
@@ -382,8 +430,8 @@ void DrawGame(void)
if
(
brick
[
i
][
j
].
active
)
{
if
(
brick
[
i
][
j
].
couleur
==
1
)
DrawRectangle
(
brick
[
i
][
j
].
position
.
x
-
brickSize
.
x
/
2
,
brick
[
i
][
j
].
position
.
y
-
brickSize
.
y
/
2
,
brickSize
.
x
,
brickSize
.
y
,
BLUE
);
else
if
(
brick
[
i
][
j
].
couleur
==
3
)
DrawRectangle
(
brick
[
i
][
j
].
position
.
x
-
brickSize
.
x
/
2
,
brick
[
i
][
j
].
position
.
y
-
brickSize
.
y
/
2
,
brickSize
.
x
,
brickSize
.
y
,
PURPLE
);
else
if
(
brick
[
i
][
j
].
couleur
==
2
)
DrawRectangle
(
brick
[
i
][
j
].
position
.
x
-
brickSize
.
x
/
2
,
brick
[
i
][
j
].
position
.
y
-
brickSize
.
y
/
2
,
brickSize
.
x
,
brickSize
.
y
,
BLACK
);
else
if
(
brick
[
i
][
j
].
couleur
==
3
)
DrawRectangle
(
brick
[
i
][
j
].
position
.
x
-
brickSize
.
x
/
2
,
brick
[
i
][
j
].
position
.
y
-
brickSize
.
y
/
2
,
brickSize
.
x
,
brickSize
.
y
,
PURPLE
);
else
if
((
i
+
j
)
%
2
==
0
)
DrawRectangle
(
brick
[
i
][
j
].
position
.
x
-
brickSize
.
x
/
2
,
brick
[
i
][
j
].
position
.
y
-
brickSize
.
y
/
2
,
brickSize
.
x
,
brickSize
.
y
,
GRAY
);
else
DrawRectangle
(
brick
[
i
][
j
].
position
.
x
-
brickSize
.
x
/
2
,
brick
[
i
][
j
].
position
.
y
-
brickSize
.
y
/
2
,
brickSize
.
x
,
brickSize
.
y
,
DARKGRAY
);
}
...
...
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