Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProjetZZ1
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc BERET
ProjetZZ1
Commits
ccb1c5c6
Commit
ccb1c5c6
authored
Jun 20, 2022
by
antoinemeyer5
Browse files
Options
Downloads
Patches
Plain Diff
exercice x fenetre termine et valide par M.Laurencot
parent
780fbe42
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
travail_individuel/Meyer/x_fenetre/main
+0
-0
0 additions, 0 deletions
travail_individuel/Meyer/x_fenetre/main
travail_individuel/Meyer/x_fenetre/main.c
+68
-9
68 additions, 9 deletions
travail_individuel/Meyer/x_fenetre/main.c
with
68 additions
and
9 deletions
travail_individuel/Meyer/x_fenetre/main
+
0
−
0
View file @
ccb1c5c6
No preview for this file type
This diff is collapsed.
Click to expand it.
travail_individuel/Meyer/x_fenetre/main.c
+
68
−
9
View file @
ccb1c5c6
#include
<SDL2/SDL.h>
#include
<SDL2/SDL.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<time.h>
#include
<math.h>
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
...
@@ -14,6 +17,8 @@ int main(int argc, char **argv)
...
@@ -14,6 +17,8 @@ int main(int argc, char **argv)
int
window_x
;
int
window_x
;
int
window_y
;
int
window_y
;
int
number_of_stars
=
10
;
SDL_InitSubSystem
(
SDL_INIT_VIDEO
);
SDL_InitSubSystem
(
SDL_INIT_VIDEO
);
SDL_DisplayMode
mode
;
SDL_DisplayMode
mode
;
int
display_width
;
int
display_width
;
...
@@ -39,7 +44,7 @@ int main(int argc, char **argv)
...
@@ -39,7 +44,7 @@ int main(int argc, char **argv)
window_x
=
(
display_width
-
window_width
)
/
2
;
window_x
=
(
display_width
-
window_width
)
/
2
;
window_y
=
display_height
;
window_y
=
display_height
;
window
=
SDL_CreateWindow
(
window
=
SDL_CreateWindow
(
"Rocket"
,
"Rocket
: 3
"
,
window_x
,
window_y
,
// centrage de la fenêtre
window_x
,
window_y
,
// centrage de la fenêtre
window_width
,
window_height
,
// largeur = 400, hauteur = 300
window_width
,
window_height
,
// largeur = 400, hauteur = 300
SDL_WINDOW_RESIZABLE
);
// redimensionnable
SDL_WINDOW_RESIZABLE
);
// redimensionnable
...
@@ -52,17 +57,71 @@ int main(int argc, char **argv)
...
@@ -52,17 +57,71 @@ int main(int argc, char **argv)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
// decompte decollage
SDL_Delay
(
1000
);
SDL_SetWindowTitle
(
window
,
"Rocket : 2"
);
SDL_Delay
(
1000
);
SDL_SetWindowTitle
(
window
,
"Rocket : 1"
);
SDL_Delay
(
1000
);
SDL_SetWindowTitle
(
window
,
"Rocket : FEU!"
);
SDL_Delay
(
1000
);
SDL_SetWindowTitle
(
window
,
"Rocket"
);
while
(
window_y
>
0
)
while
(
window_y
>
0
){
{
window_width
=
window_width
-
15
;
window_x
=
(
display_width
-
window_width
)
/
2
;
window_y
=
window_y
-
100
;
window_y
=
window_y
-
100
;
SDL_SetWindowSize
(
window
,
window_width
,
window_height
);
SDL_SetWindowPosition
(
window
,
window_x
,
window_y
);
SDL_SetWindowPosition
(
window
,
window_x
,
window_y
);
SDL_Delay
(
10
00
);
// Pause exprimée en ms
SDL_Delay
(
2
00
);
// Pause exprimée en ms
}
}
/
*
e
t on referme tout ce qu'on a ouvert en ordre inverse de la création */
/
/
e
xplosion de la rocket
SDL_DestroyWindow
(
window
);
// la fenêtre
SDL_DestroyWindow
(
window
);
// la fenêtre
// aleatoire
srand
(
time
(
0
));
// creation de [number_of_stars] etoiles dans des directions aleatoires
SDL_Window
*
window_stars
[
20
];
int
tab_window_x
[
20
];
int
tab_window_y
[
20
];
int
tab_direction
[
20
];
for
(
int
i
=
1
;
i
<=
number_of_stars
;
i
++
)
{
int
width_r
=
50
+
rand
()
%
100
;
int
height_r
=
50
+
rand
()
%
50
;
tab_window_x
[
i
]
=
(
display_width
-
width_r
)
/
2
;
tab_window_y
[
i
]
=
0
;
tab_direction
[
i
]
=
pow
(
-
1
,
1
+
(
rand
()
%
2
));
// donne -1 ou 1
window_stars
[
i
]
=
SDL_CreateWindow
(
"Étoile"
,
tab_window_x
[
i
],
tab_window_y
[
i
],
width_r
,
height_r
,
SDL_WINDOW_RESIZABLE
);
SDL_Delay
(
10
);
// Pause exprimée en ms
}
// déplacement des etoiles
for
(
int
temps
=
0
;
temps
<=
5
;
temps
++
)
{
for
(
int
i
=
1
;
i
<=
number_of_stars
;
i
++
)
{
tab_window_y
[
i
]
=
tab_window_y
[
i
]
+
20
+
rand
()
%
70
;
tab_window_x
[
i
]
=
tab_window_x
[
i
]
+
tab_direction
[
i
]
*
(
rand
()
%
200
);
SDL_SetWindowPosition
(
window_stars
[
i
],
tab_window_x
[
i
],
tab_window_y
[
i
]);
}
SDL_Delay
(
400
);
}
// destruction des etoiles
for
(
int
i
=
1
;
i
<=
number_of_stars
;
i
++
)
{
SDL_DestroyWindow
(
window_stars
[
i
]);
}
SDL_Quit
();
// la SDL
SDL_Quit
();
// la SDL
return
0
;
return
0
;
...
...
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