Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SpaceInvaders_upgrade
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
Lila NICKLER
SpaceInvaders_upgrade
Commits
70df5426
Commit
70df5426
authored
Oct 29, 2020
by
Lila NICKLER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolution de pb sur l'item 3 bonus shoot
parent
faf99d87
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
61 deletions
+64
-61
space_invaders.c
space_invaders.c
+64
-61
No files found.
space_invaders.c
View file @
70df5426
...
...
@@ -92,6 +92,7 @@ static float alpha = 0.0f;
static
int
activeEnemies
=
0
;
static
int
enemiesKill
=
0
;
static
bool
smooth
=
false
;
static
int
ItemNumberWave
=
1
;
//------------------------------------------------------------------------------------
// Module Functions Declaration (local)
...
...
@@ -222,7 +223,7 @@ void InitGame(void)
item
[
i
].
color
=
GRAY
;
break
;
}
item
[
i
].
active
=
fals
e
;
item
[
i
].
active
=
tru
e
;
}
...
...
@@ -241,20 +242,15 @@ void UpdateGame(void)
{
case
FIRST
:
{
item
[
0
].
active
=
true
;
if
(
!
smooth
)
{
alpha
+=
0
.
02
f
;
if
(
alpha
>=
1
.
0
f
)
smooth
=
true
;
for
(
int
i
=
0
;
i
<
ItemNumber
;
i
++
)
{
item
[
i
].
effect
=
GetRandomValue
(
0
,
2
);
}
}
if
(
smooth
)
alpha
-=
0
.
02
f
;
if
(
enemiesKill
==
activeEnemies
)
{
enemiesKill
=
0
;
...
...
@@ -264,16 +260,14 @@ void UpdateGame(void)
if
(
!
enemy
[
i
].
active
)
enemy
[
i
].
active
=
true
;
}
for
(
int
i
=
0
;
i
<
ItemNumber
;
i
++
)
{
item
[
i
].
effect
=
GetRandomValue
(
0
,
2
);
}
activeEnemies
=
SECOND_WAVE
;
wave
=
SECOND
;
smooth
=
false
;
alpha
=
0
.
0
f
;
}
ItemNumberWave
=
2
;
}
break
;
case
SECOND
:
{
if
(
!
smooth
)
...
...
@@ -284,7 +278,7 @@ void UpdateGame(void)
}
if
(
smooth
)
alpha
-=
0
.
02
f
;
if
(
enemiesKill
==
activeEnemies
)
{
enemiesKill
=
0
;
...
...
@@ -303,10 +297,6 @@ void UpdateGame(void)
enemy
[
i
].
boss
=
false
;
enemy
[
i
].
life
=
10
;
}
for
(
int
i
=
0
;
i
<
ItemNumber
;
i
++
)
{
item
[
i
].
effect
=
GetRandomValue
(
0
,
2
);
}
activeEnemies
=
THIRD_WAVE
;
wave
=
THIRD
;
...
...
@@ -358,18 +348,14 @@ void UpdateGame(void)
for
(
int
i
=
0
;
i
<
activeEnemies
;
i
++
)
{
if
(
!
enemy
[
i
].
active
)
enemy
[
i
].
active
=
true
;
}
for
(
int
i
=
0
;
i
<
ItemNumber
;
i
++
)
{
item
[
i
].
effect
=
GetRandomValue
(
0
,
2
);
}
activeEnemies
=
FOURTH_WAVE
;
wave
=
FOURTH
;
smooth
=
false
;
alpha
=
0
.
0
f
;
}
ItemNumberWave
=
3
;
}
break
;
case
FOURTH
:
{
...
...
@@ -407,44 +393,62 @@ void UpdateGame(void)
enemy
[
i
].
rec
.
x
=
GetRandomValue
(
screenWidth
,
screenWidth
+
1000
);
enemy
[
i
].
rec
.
y
=
GetRandomValue
(
0
,
screenHeight
-
enemy
[
i
].
rec
.
height
);
player
.
life
--
;
}
// Perte du bonus
player
.
speed
.
x
=
5
;
player
.
speed
.
y
=
5
;
for
(
int
i
=
0
;
i
<
NUM_SHOOTS
;
i
++
)
{
shoot
[
i
].
rec
.
width
=
10
;
shoot
[
i
].
rec
.
height
=
5
;
shoot
[
i
].
color
=
MAROON
;
shoot
[
i
].
bonus
=
false
;
}
}
}
// Player get item
for
(
int
i
=
0
;
i
<
ItemNumber
;
i
++
)
{
if
(
CheckCollisionRecs
(
player
.
rec
,
item
[
i
].
rec
))
{
if
(
item
[
i
].
active
)
{
item
[
i
].
active
=
false
;
if
(
i
==
ItemNumber
-
1
)
{
item
[
0
].
active
=
true
;
}
else
{
item
[
i
+
1
].
active
=
true
;
}
item
[
i
].
rec
.
x
=
GetRandomValue
(
screenWidth
,
screenWidth
+
1000
);
item
[
i
].
rec
.
y
=
GetRandomValue
(
0
,
screenHeight
-
item
[
i
].
rec
.
height
);
switch
(
item
[
i
].
effect
)
if
(
CheckCollisionRecs
(
player
.
rec
,
item
[
i
].
rec
))
{
case
Life
:
player
.
life
++
;
break
;
case
Speed
:
player
.
speed
.
x
+=
2
;
player
.
speed
.
y
+=
2
;
break
;
case
SizeShoot
:
for
(
int
i
;
i
<
NUM_SHOOTS
;
i
++
)
item
[
i
].
active
=
false
;
if
(
i
==
ItemNumber
-
1
)
{
shoot
[
i
].
bonus
=
true
;
item
[
0
].
active
=
true
;
}
else
{
item
[
i
+
1
].
active
=
true
;
}
item
[
i
].
rec
.
x
=
GetRandomValue
(
screenWidth
,
screenWidth
+
1000
);
item
[
i
].
rec
.
y
=
GetRandomValue
(
0
,
screenHeight
-
item
[
i
].
rec
.
height
);
switch
(
item
[
i
].
effect
)
{
case
Life
:
player
.
life
++
;
break
;
case
Speed
:
if
(
player
.
speed
.
x
<
10
)
{
player
.
speed
.
x
+=
2
;
player
.
speed
.
y
+=
2
;
}
break
;
case
SizeShoot
:
for
(
int
i
=
0
;
i
<
NUM_SHOOTS
;
i
++
)
{
shoot
[
i
].
bonus
=
true
;
shoot
[
i
].
color
=
YELLOW
;
}
break
;
default:
break
;
}
break
;
default:
break
;
}
}
}
...
...
@@ -467,7 +471,7 @@ void UpdateGame(void)
}
}
}
// Wall behaviour
if
(
player
.
rec
.
x
<=
0
)
player
.
rec
.
x
=
0
;
if
(
player
.
rec
.
x
+
player
.
rec
.
width
>=
screenWidth
)
player
.
rec
.
x
=
screenWidth
-
player
.
rec
.
width
;
...
...
@@ -485,14 +489,13 @@ void UpdateGame(void)
{
if
(
shoot
[
i
].
bonus
)
{
shoot
[
i
].
rec
.
x
=
player
.
rec
.
x
+
2
;
shoot
[
i
].
rec
.
y
=
player
.
rec
.
y
+
player
.
rec
.
height
/
4
+
2
;
shoot
[
i
].
active
=
true
;
}
else
{
shoot
[
i
].
rec
.
height
=
10
;
shoot
[
i
].
rec
.
width
=
20
;
}
shoot
[
i
].
rec
.
x
=
player
.
rec
.
x
;
shoot
[
i
].
rec
.
y
=
player
.
rec
.
y
+
player
.
rec
.
height
/
4
;
shoot
[
i
].
active
=
true
;
}
break
;
}
}
...
...
@@ -529,7 +532,6 @@ void UpdateGame(void)
score
+=
100
;
}
}
if
(
shoot
[
i
].
rec
.
x
+
shoot
[
i
].
rec
.
width
>=
screenWidth
)
{
shoot
[
i
].
active
=
false
;
...
...
@@ -546,7 +548,6 @@ void UpdateGame(void)
if
(
item
[
i
].
active
)
{
item
[
i
].
rec
.
x
-=
item
[
i
].
speed
.
x
;
item
[
i
].
effect
=
GetRandomValue
(
0
,
2
);
if
(
item
[
i
].
rec
.
x
<
0
)
{
...
...
@@ -599,7 +600,9 @@ void DrawGame(void)
}
for
(
int
i
=
0
;
i
<
ItemNumber
;
i
++
)
{
if
(
item
[
i
].
active
)
DrawRectangleRec
(
item
[
i
].
rec
,
item
[
i
].
color
);
if
(
item
[
i
].
active
)
{
DrawRectangleRec
(
item
[
i
].
rec
,
item
[
i
].
color
);
}
}
...
...
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