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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc BERET
ProjetZZ1
Commits
807286d8
Commit
807286d8
authored
2 years ago
by
antoinemeyer5
Browse files
Options
Downloads
Patches
Plain Diff
fin de l'exercice pave de serpents
parent
693a9ac1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
travail_individuel/Meyer/pave_de_serpents/main
+0
-0
0 additions, 0 deletions
travail_individuel/Meyer/pave_de_serpents/main
travail_individuel/Meyer/pave_de_serpents/main.c
+89
-64
89 additions, 64 deletions
travail_individuel/Meyer/pave_de_serpents/main.c
with
89 additions
and
64 deletions
travail_individuel/Meyer/pave_de_serpents/main
+
0
−
0
View file @
807286d8
No preview for this file type
This diff is collapsed.
Click to expand it.
travail_individuel/Meyer/pave_de_serpents/main.c
+
89
−
64
View file @
807286d8
#include
<SDL2/SDL.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<math.h>
#define PI 3.141592654
int
main
(
int
argc
,
char
**
argv
)
{
(
void
)
argc
;
(
void
)
argv
;
int
vainqueur
=
0
;
SDL_Window
*
window
=
NULL
;
...
...
@@ -25,8 +25,14 @@ int main(int argc, char **argv)
SDL_Renderer
*
renderer
;
SDL_Rect
rect
;
int
pale_1_x
;
int
pale_1_y
;
int
pale_1_x
=
300
;
int
pale_1_y
=
300
;
int
pale_2_x
=
700
;
int
pale_2_y
=
300
;
int
pale_3_x
=
250
;
int
pale_3_y
=
500
;
if
(
SDL_GetDesktopDisplayMode
(
0
,
&
mode
)
!=
0
)
{
...
...
@@ -70,67 +76,86 @@ int main(int argc, char **argv)
exit
(
EXIT_FAILURE
);
}
// dessin
/* couleur de fond */
SDL_SetRenderDrawColor
(
renderer
,
157
,
224
,
144
,
255
);
SDL_RenderClear
(
renderer
);
//sol
SDL_SetRenderDrawColor
(
renderer
,
49
,
150
,
29
,
255
);
rect
.
w
=
window_width
;
rect
.
h
=
window_height
/
3
;
rect
.
x
=
0
;
rect
.
y
=
window_height
-
window_height
/
3
;
SDL_RenderFillRect
(
renderer
,
&
rect
);
/* bloc du moulin */
SDL_SetRenderDrawColor
(
renderer
,
255
,
255
,
255
,
255
);
rect
.
w
=
150
;
rect
.
h
=
250
;
rect
.
x
=
(
window_width
-
rect
.
w
)
/
2
;
rect
.
y
=
window_height
-
rect
.
h
-
150
;
SDL_RenderFillRect
(
renderer
,
&
rect
);
/*triangle moulin*/
SDL_SetRenderDrawColor
(
renderer
,
255
,
0
,
0
,
255
);
rect
.
w
=
150
;
rect
.
h
=
50
;
rect
.
x
=
(
window_width
-
rect
.
w
)
/
2
;
rect
.
y
=
window_height
-
rect
.
h
-
400
;
SDL_RenderFillRect
(
renderer
,
&
rect
);
//pales du moulin
//pale 1 du moulin
pale_1_x
=
50
;
pale_1_y
=
50
;
SDL_SetRenderDrawColor
(
renderer
,
163
,
82
,
2
,
255
);
SDL_RenderDrawLine
(
renderer
,
(
window_width
-
rect
.
w
)
/
2
,
window_height
-
rect
.
h
-
400
,
pale_1_x
,
pale_1_y
);
/* afficher à l'ecran */
SDL_RenderPresent
(
renderer
);
// départ de la course
/*while (vainqueur == 0)
{
if (cercle.x > display_width)
{
vainqueur = 1;
}
}*/
// ecrire victoire
int
i
=
20
;
while
(
i
>
0
){
// dessin
/* couleur de fond */
SDL_SetRenderDrawColor
(
renderer
,
157
,
224
,
144
,
255
);
SDL_RenderClear
(
renderer
);
//sol
SDL_SetRenderDrawColor
(
renderer
,
49
,
150
,
29
,
255
);
rect
.
w
=
window_width
;
rect
.
h
=
window_height
/
3
;
rect
.
x
=
0
;
rect
.
y
=
window_height
-
window_height
/
3
;
SDL_RenderFillRect
(
renderer
,
&
rect
);
/* bloc du moulin */
SDL_SetRenderDrawColor
(
renderer
,
255
,
255
,
255
,
255
);
rect
.
w
=
150
;
rect
.
h
=
250
;
rect
.
x
=
(
window_width
-
rect
.
w
)
/
2
;
rect
.
y
=
window_height
-
rect
.
h
-
150
;
SDL_RenderFillRect
(
renderer
,
&
rect
);
/*triangle moulin*/
SDL_SetRenderDrawColor
(
renderer
,
255
,
0
,
0
,
255
);
rect
.
w
=
150
;
rect
.
h
=
50
;
rect
.
x
=
(
window_width
-
rect
.
w
)
/
2
;
rect
.
y
=
window_height
-
rect
.
h
-
400
;
SDL_RenderFillRect
(
renderer
,
&
rect
);
//pales du moulin
//pale 1 du moulin
int
theta
=
40
;
int
px
=
window_width
/
2
;
int
py
=
window_height
-
rect
.
h
-
375
;
float
c
=
cos
(
theta
),
s
=
sin
(
theta
);
float
dx
=
pale_1_x
-
px
,
dy
=
pale_1_y
-
py
;
pale_1_x
=
pale_1_x
+
c
*
dx
-
s
*
dy
;
pale_1_y
=
pale_1_y
+
s
*
dx
+
c
*
dy
;
SDL_SetRenderDrawColor
(
renderer
,
163
,
82
,
2
,
255
);
SDL_RenderDrawLine
(
renderer
,
px
,
py
,
pale_1_x
,
pale_1_y
);
//pale 2 du moulin
dx
=
pale_2_x
-
px
,
dy
=
pale_2_y
-
py
;
pale_2_x
=
pale_2_x
+
c
*
dx
-
s
*
dy
;
pale_2_y
=
pale_2_y
+
s
*
dx
+
c
*
dy
;
SDL_SetRenderDrawColor
(
renderer
,
163
,
82
,
2
,
255
);
SDL_RenderDrawLine
(
renderer
,
px
,
py
,
pale_2_x
,
pale_2_y
);
//pale 3 du moulin
dx
=
pale_3_x
-
px
,
dy
=
pale_3_y
-
py
;
pale_3_x
=
pale_3_x
+
c
*
dx
-
s
*
dy
;
pale_3_y
=
pale_3_y
+
s
*
dx
+
c
*
dy
;
SDL_SetRenderDrawColor
(
renderer
,
163
,
82
,
2
,
255
);
SDL_RenderDrawLine
(
renderer
,
px
,
py
,
pale_3_x
,
pale_3_y
);
/* afficher à l'ecran */
SDL_RenderPresent
(
renderer
);
SDL_Delay
(
1000
);
SDL_RenderClear
(
renderer
);
i
=
i
-
2
;
}
SDL_De
lay
(
2000
);
SDL_De
stroyRenderer
(
renderer
);
// fermer fenetre
SDL_DestroyWindow
(
window
);
// la fenêtre
...
...
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