Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TP7projet_jeu_air_defense
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
MARQUE Pierre
TP7projet_jeu_air_defense
Commits
cd4f5c83
Commit
cd4f5c83
authored
Nov 02, 2020
by
Pierre MARQUE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tout fini
parent
2e75d74a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
56 deletions
+80
-56
air_defense.c
air_defense.c
+76
-56
air_defense.exe
air_defense.exe
+0
-0
air_defense.h
air_defense.h
+4
-0
No files found.
air_defense.c
View file @
cd4f5c83
...
...
@@ -90,8 +90,9 @@ Music gamePauseMusic;
const
char
*
explosion
=
"Musiques/explosion.wav"
;
const
char
*
alert
=
"Musiques/Alerte.wav"
;
const
char
*
bombshellC
=
"Musiques/Missile
-launch-Sound-effect
.wav"
;
const
char
*
bombshellC
=
"Musiques/Missile.wav"
;
const
char
*
bulletC
=
"Musiques/APC.wav"
;
Wave
wave
;
Sound
soundExplosion
;
Sound
soundAlert
;
Sound
soundBombshell
;
...
...
@@ -137,7 +138,10 @@ int main(void)
PlayMusicStream
(
gamePauseMusic
);
UpdateMusicStream
(
gamePauseMusic
);
}
// Update
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
...
...
@@ -233,7 +237,7 @@ void UpdateGame(void)
{
paratrooper
[
i
]
=
MoveParatrooper
(
paratrooper
[
i
]);
}
if
(
IsRectangleOut
(
paratrooper
[
i
].
hitbox
))
if
(
IsRectangleOut
(
paratrooper
[
i
].
hitbox
)
&&
paratrooper
[
i
].
droped
)
{
paratrooper
[
i
]
=
InitializeParatrooper
();
life
--
;
...
...
@@ -304,12 +308,7 @@ void UpdateGame(void)
{
if
(
!
bombshells
[
i
].
ammoShot
)
{
bombshells
[
i
].
ammoShot
=
true
;
bombshells
[
i
].
position
.
x
=
antiAircraftCanon
.
position
.
x
;
bombshells
[
i
].
position
.
y
=
antiAircraftCanon
.
position
.
y
;
bombshells
[
i
].
speed
.
x
=
bombshellSpeed
*
antiAircraftCanon
.
cos
;
bombshells
[
i
].
speed
.
y
=
bombshellSpeed
*
antiAircraftCanon
.
sin
;
PlaySound
(
soundBombshell
);
bombshells
[
i
]
=
ShootBombshell
(
bombshells
[
i
]);
break
;
}
}
...
...
@@ -321,12 +320,7 @@ void UpdateGame(void)
{
if
(
!
bullet
[
i
].
ammoShot
)
{
bullet
[
i
].
ammoShot
=
true
;
bullet
[
i
].
position
.
x
=
antiParaCanon
.
position
.
x
;
bullet
[
i
].
position
.
y
=
antiParaCanon
.
position
.
y
;
bullet
[
i
].
speed
.
x
=
bulletSpeed
*
antiParaCanon
.
cos
;
bullet
[
i
].
speed
.
y
=
bulletSpeed
*
antiParaCanon
.
sin
;
PlaySound
(
soundBullet
);
bullet
[
i
]
=
ShootBullet
(
bullet
[
i
]);
break
;
}
}
...
...
@@ -399,46 +393,17 @@ void UpdateGame(void)
}
}
//Dropping paratroopers
if
(
aircraft
[
i
].
speed
.
x
>
0
)
{
if
(
aircraft
[
i
].
hitbox
.
x
>
aircraft
[
i
].
xFirstToJump
)
{
for
(
int
j
=
0
;
j
<
NUMBER_MAX_OF_PARATROOPERS
;
j
++
)
{
if
((
!
paratrooper
[
j
].
droped
)
&&
(
aircraft
[
i
].
hitbox
.
x
>
aircraft
[
i
].
xFirstToJump
+
20
)
&&
(
aircraft
[
i
].
numberOfParatroopers
>
-
1
))
{
paratrooper
[
j
].
droped
=
true
;
paratrooper
[
j
].
whichWay
=
false
;
paratrooper
[
j
].
hitbox
.
x
=
aircraft
[
i
].
hitbox
.
x
;
paratrooper
[
j
].
hitbox
.
y
=
aircraft
[
i
].
hitbox
.
y
;
paratrooper
[
j
].
xDrop
=
aircraft
[
i
].
hitbox
.
x
;
paratrooper
[
j
].
yDrop
=
aircraft
[
i
].
hitbox
.
y
;
aircraft
[
i
].
numberOfParatroopers
--
;
aircraft
[
i
].
xFirstToJump
=
aircraft
[
i
].
hitbox
.
x
;
}
}
}
}
else
{
if
(
aircraft
[
i
].
hitbox
.
x
<
aircraft
[
i
].
xFirstToJump
)
{
for
(
int
j
=
0
;
j
<
NUMBER_MAX_OF_PARATROOPERS
;
j
++
)
if
(
GoDropParatrooper
(
aircraft
[
i
]))
{
for
(
int
j
=
0
;
j
<
NUMBER_MAX_OF_PARATROOPERS
;
j
++
)
{
if
((
!
paratrooper
[
j
].
droped
)
&&
(
fabs
(
aircraft
[
i
].
hitbox
.
x
-
aircraft
[
i
].
xFirstToJump
)
>
20
)
&&
(
aircraft
[
i
].
numberOfParatroopers
>
-
1
))
{
if
((
!
paratrooper
[
j
].
droped
)
&&
(
aircraft
[
i
].
hitbox
.
x
<
aircraft
[
i
].
xFirstToJump
-
20
)
&&
(
aircraft
[
i
].
numberOfParatroopers
>
-
1
))
{
paratrooper
[
j
].
droped
=
true
;
paratrooper
[
j
].
whichWay
=
true
;
paratrooper
[
j
].
xDrop
=
aircraft
[
i
].
hitbox
.
x
;
paratrooper
[
j
].
yDrop
=
aircraft
[
i
].
hitbox
.
y
;
paratrooper
[
j
].
hitbox
.
x
=
aircraft
[
i
].
hitbox
.
x
;
paratrooper
[
j
].
hitbox
.
y
=
aircraft
[
i
].
hitbox
.
y
;
aircraft
[
i
].
numberOfParatroopers
--
;
aircraft
[
i
].
xFirstToJump
=
aircraft
[
i
].
hitbox
.
x
;
}
paratrooper
[
j
]
=
DropParatrooperFromAircraft
(
paratrooper
[
j
],
aircraft
[
i
]);
aircraft
[
i
].
numberOfParatroopers
--
;
aircraft
[
i
].
xFirstToJump
=
aircraft
[
i
].
hitbox
.
x
;
}
}
}
}
}
}
...
...
@@ -528,7 +493,8 @@ void DrawGame(void)
if
(
framesCounter
%
16
<
8
)
{
DrawText
(
"ALERT -- Invaders close to contact --"
,
0
,
500
,
20
,
GREEN
);
DrawText
(
">> <<"
,
paratrooper
[
i
].
hitbox
.
x
-
12
,
paratrooper
[
i
].
hitbox
.
y
-
4
,
20
,
GREEN
);
DrawText
(
">> <<"
,
paratrooper
[
i
].
hitbox
.
x
-
12
,
paratrooper
[
i
].
hitbox
.
y
-
4
,
20
,
GREEN
);
PlaySound
(
soundAlert
);
}
}
}
...
...
@@ -566,6 +532,7 @@ void LoadAudio(void)
gameOverMusic
=
LoadMusicStream
(
beams
);
gamePauseMusic
=
LoadMusicStream
(
Dust
);
//Sounds
soundExplosion
=
LoadSound
(
explosion
);
soundBullet
=
LoadSound
(
bulletC
);
soundBombshell
=
LoadSound
(
bombshellC
);
...
...
@@ -610,13 +577,13 @@ Aircraft InitializeAircraft(void)
{
aircraft
.
hitbox
.
x
=
-
GetRandomValue
(
0
,
300
);
aircraft
.
speed
.
x
=
0
.
5
+
0
.
5
*
((
float
)
GetRandomValue
(
0
,
1
));
aircraft
.
xFirstToJump
=
GetRandomValue
(
10
0
,
screenWidth
/
2
);
aircraft
.
xFirstToJump
=
GetRandomValue
(
8
0
,
screenWidth
/
2
);
}
else
{
aircraft
.
speed
.
x
=
-
(
0
.
5
+
0
.
5
*
((
float
)
GetRandomValue
(
0
,
1
)));
aircraft
.
hitbox
.
x
=
GetRandomValue
(
screenWidth
,
screenWidth
+
300
);
aircraft
.
xFirstToJump
=
GetRandomValue
(
screenWidth
/
2
,
screenWidth
-
10
0
);
aircraft
.
xFirstToJump
=
GetRandomValue
(
screenWidth
/
2
,
screenWidth
-
8
0
);
}
aircraft
.
speed
.
y
=
0
;
aircraft
.
color
=
GRAY
;
...
...
@@ -753,6 +720,19 @@ bool IsCircleOut(Vector2 center, float radius)
return
false
;
}
bool
GoDropParatrooper
(
Aircraft
aircraft
)
{
if
(
aircraft
.
speed
.
x
>
0
&&
aircraft
.
hitbox
.
x
>
aircraft
.
xFirstToJump
)
{
return
true
;
}
if
(
aircraft
.
speed
.
x
<
0
&&
aircraft
.
hitbox
.
x
<
aircraft
.
xFirstToJump
)
{
return
true
;
}
return
false
;
}
Aircraft
MoveAircrafts
(
Aircraft
aircraft
)
{
aircraft
.
hitbox
.
x
+=
aircraft
.
speed
.
x
;
...
...
@@ -767,6 +747,17 @@ Bullet MoveBullet(Bullet bullet)
return
bullet
;
}
Bullet
ShootBullet
(
Bullet
bullet
)
{
bullet
.
ammoShot
=
true
;
bullet
.
position
.
x
=
antiParaCanon
.
position
.
x
;
bullet
.
position
.
y
=
antiParaCanon
.
position
.
y
;
bullet
.
speed
.
x
=
bulletSpeed
*
antiParaCanon
.
cos
;
bullet
.
speed
.
y
=
bulletSpeed
*
antiParaCanon
.
sin
;
PlaySound
(
soundBullet
);
return
bullet
;
}
Bombshell
MoveBombshell
(
Bombshell
bombshell
)
{
bombshell
.
position
.
x
+=
bombshell
.
speed
.
x
;
...
...
@@ -774,6 +765,35 @@ Bombshell MoveBombshell(Bombshell bombshell)
return
bombshell
;
}
Bombshell
ShootBombshell
(
Bombshell
bombshell
)
{
bombshell
.
ammoShot
=
true
;
bombshell
.
position
.
x
=
antiAircraftCanon
.
position
.
x
;
bombshell
.
position
.
y
=
antiAircraftCanon
.
position
.
y
;
bombshell
.
speed
.
x
=
bombshellSpeed
*
antiAircraftCanon
.
cos
;
bombshell
.
speed
.
y
=
bombshellSpeed
*
antiAircraftCanon
.
sin
;
PlaySound
(
soundBombshell
);
return
bombshell
;
}
Paratrooper
DropParatrooperFromAircraft
(
Paratrooper
paratrooper
,
Aircraft
aircraft
)
{
paratrooper
.
droped
=
true
;
if
(
aircraft
.
speed
.
x
>
0
)
{
paratrooper
.
whichWay
=
false
;
}
else
{
paratrooper
.
whichWay
=
true
;
}
paratrooper
.
hitbox
.
x
=
aircraft
.
hitbox
.
x
;
paratrooper
.
hitbox
.
y
=
aircraft
.
hitbox
.
y
;
paratrooper
.
xDrop
=
aircraft
.
hitbox
.
x
;
paratrooper
.
yDrop
=
aircraft
.
hitbox
.
y
;
return
paratrooper
;
}
Paratrooper
MoveParatrooper
(
Paratrooper
paratrooper
)
{
paratrooper
.
hitbox
.
y
+=
paratrooper
.
speed
.
y
;
...
...
air_defense.exe
View file @
cd4f5c83
No preview for this file type
air_defense.h
View file @
cd4f5c83
...
...
@@ -105,8 +105,12 @@ Viewfinder InitializeViewfinder(float decalage);
bool
IsRectangleOut
(
Rectangle
rec
);
bool
IsCircleOut
(
Vector2
center
,
float
radius
);
bool
GoDropParatrooper
(
Aircraft
aircraft
);
Aircraft
MoveAircrafts
(
Aircraft
aircraft
);
Bombshell
MoveBombshell
(
Bombshell
bombshell
);
Bombshell
ShootBombshell
(
Bombshell
bombshell
);
Bullet
MoveBullet
(
Bullet
bullet
);
Bullet
ShootBullet
(
Bullet
bullet
);
Paratrooper
DropParatrooperFromAircraft
(
Paratrooper
paratrooper
,
Aircraft
aircraft
);
Paratrooper
MoveParatrooper
(
Paratrooper
paratrooper
);
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