Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mathodo2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MOULIAS Mattheo
Mathodo2
Commits
1456d624
Commit
1456d624
authored
2 years ago
by
SmallIshMink
Browse files
Options
Downloads
Patches
Plain Diff
Ajout de la partie 3 Oublié
parent
9cb777f7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.c
+17
-6
17 additions, 6 deletions
main.c
main.o
+0
-0
0 additions, 0 deletions
main.o
spacecorridor.exe
+0
-0
0 additions, 0 deletions
spacecorridor.exe
with
17 additions
and
6 deletions
main.c
+
17
−
6
View file @
1456d624
...
...
@@ -66,6 +66,7 @@ struct textures_s{
SDL_Texture
*
background
;
/*!< Texture liée à l'image du fond de l'écran. */
SDL_Texture
*
ship
;
/*!< Texture liée à l'image du vaisseau. */
SDL_Texture
*
meteorite
;
/*!< Texture liée à l'image du météorite. */
SDL_Texture
*
finishLine
;
/*!< Texture liée à l'image de la ligne d'arrivée. */
/* A COMPLETER */
};
...
...
@@ -97,6 +98,7 @@ typedef struct sprite_s sprite_t;
struct
world_s
{
sprite_t
*
vaisseau
;
/*!< Représentation du vaisseau */
sprite_t
*
mur
;
/*!< Représentation du météorite */
sprite_t
*
ligneArriver
;
int
gameover
;
/*!< Champ indiquant si l'on est à la fin du jeu */
int
speed_h
;
/*!< Vitesse de déplacement horizontal des éléments du jeu */
...
...
@@ -127,11 +129,13 @@ void print_sprite(sprite_t *sprite){
* \param w
* \param h
*/
void
init_sprite
(
sprite_t
*
sprite
,
int
x
,
int
y
,
int
w
,
int
h
){
sprite_t
*
init_sprite
(
sprite_t
*
sprite
,
int
x
,
int
y
,
int
w
,
int
h
){
sprite
=
malloc
(
sizeof
(
sprite_t
));
sprite
->
x
=
x
;
sprite
->
y
=
y
;
sprite
->
w
=
w
;
sprite
->
h
=
h
;
return
sprite
;
}
/**
...
...
@@ -147,10 +151,11 @@ void init_data(world_t * world){
world
->
speed_h
=
0
;
// Initialisation du vaisseau
world
->
vaisseau
=
malloc
(
sizeof
(
sprite_t
));
world
->
mur
=
malloc
(
sizeof
(
sprite_t
));
init_sprite
(
world
->
vaisseau
,
SCREEN_WIDTH
/
2
-
SHIP_SIZE
/
2
,
SCREEN_HEIGHT
-
SHIP_SIZE
,
SHIP_SIZE
,
SHIP_SIZE
);
init_sprite
(
world
->
mur
,
0
,
0
,
3
*
METEORITE_SIZE
,
7
*
METEORITE_SIZE
);
world
->
vaisseau
=
init_sprite
(
world
->
vaisseau
,
SCREEN_WIDTH
/
2
-
SHIP_SIZE
/
2
,
SCREEN_HEIGHT
-
SHIP_SIZE
,
SHIP_SIZE
,
SHIP_SIZE
);
world
->
mur
=
init_sprite
(
world
->
mur
,
0
,
0
,
3
*
METEORITE_SIZE
,
7
*
METEORITE_SIZE
);
world
->
ligneArriver
=
init_sprite
(
world
->
ligneArriver
,
0
,
-
40
,
SCREEN_WIDTH
,
FINISH_LINE_HEIGHT
);
print_sprite
(
world
->
vaisseau
);
}
...
...
@@ -189,7 +194,7 @@ int is_game_over(world_t *world){
*/
void
update_data
(
world_t
*
world
){
printf
(
"%d
\n
"
,
world
->
speed_h
)
;
world
->
ligneArriver
->
y
+=
INITIAL_SPEED
-
world
->
speed_h
;
world
->
mur
->
y
+=
INITIAL_SPEED
-
world
->
speed_h
;
}
...
...
@@ -255,6 +260,9 @@ void handle_events(SDL_Event *event,world_t *world){
void
clean_textures
(
textures_t
*
textures
){
clean_texture
(
textures
->
background
);
clean_texture
(
textures
->
ship
);
clean_texture
(
textures
->
meteorite
);
clean_texture
(
textures
->
finishLine
);
/* A COMPLETER */
}
...
...
@@ -270,6 +278,7 @@ void init_textures(SDL_Renderer *renderer, textures_t *textures){
textures
->
background
=
load_image
(
"ressources/space-background.bmp"
,
renderer
);
textures
->
ship
=
load_image
(
"ressources/spaceship.bmp"
,
renderer
);
textures
->
meteorite
=
load_image
(
"ressources/meteorite.bmp"
,
renderer
);
textures
->
finishLine
=
load_image
(
"ressources/finish_line.bmp"
,
renderer
);
/* A COMPLETER */
...
...
@@ -329,6 +338,8 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,textures_t *texture
/* A COMPLETER */
apply_sprite
(
renderer
,
textures
->
ship
,
world
->
vaisseau
);
apply_sprite
(
renderer
,
textures
->
finishLine
,
world
->
ligneArriver
);
for
(
int
i
=
0
;
i
<
world
->
mur
->
w
/
METEORITE_SIZE
;
i
++
){
for
(
int
i2
=
0
;
i2
<
world
->
mur
->
h
/
METEORITE_SIZE
;
i2
++
){
apply_wall
(
renderer
,
textures
->
meteorite
,
world
->
mur
->
x
+
i
*
METEORITE_SIZE
,
world
->
mur
->
y
+
i2
*
METEORITE_SIZE
);
...
...
This diff is collapsed.
Click to expand it.
main.o
+
0
−
0
View file @
1456d624
No preview for this file type
This diff is collapsed.
Click to expand it.
spacecorridor.exe
+
0
−
0
View file @
1456d624
No preview for this file type
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment