Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bandit_Manchot
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
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
benjamin.sitbon
Bandit_Manchot
Commits
332f87b1
Commit
332f87b1
authored
4 years ago
by
benjamin.sitbon
Browse files
Options
Downloads
Patches
Plain Diff
rajout de l'interdiction de recommencer la partie lorsque toutes les roues son déjà active
parent
c936e0c3
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
display.c
+0
-7
0 additions, 7 deletions
display.c
one_armed_bandit.c
+11
-1
11 additions, 1 deletion
one_armed_bandit.c
one_armed_bandit.h
+4
-1
4 additions, 1 deletion
one_armed_bandit.h
with
15 additions
and
9 deletions
display.c
+
0
−
7
View file @
332f87b1
...
@@ -10,9 +10,6 @@ SDL_Window* init_display(){
...
@@ -10,9 +10,6 @@ SDL_Window* init_display(){
int
one_arm_width
,
one_arm_height
;
int
one_arm_width
,
one_arm_height
;
SDL_Window
*
window
;
SDL_Window
*
window
;
// -------------------------
// Graphic initialization
// -------------------------
assert
(
SDL_Init
(
SDL_INIT_VIDEO
)
==
0
);
assert
(
SDL_Init
(
SDL_INIT_VIDEO
)
==
0
);
get_image_file_size
(
"./one_armed_bandit.png"
,
&
one_arm_width
,
&
one_arm_height
);
get_image_file_size
(
"./one_armed_bandit.png"
,
&
one_arm_width
,
&
one_arm_height
);
assert
((
window
=
SDL_CreateWindow
(
"one_armed_bandit"
,
SDL_WINDOWPOS_UNDEFINED
,
assert
((
window
=
SDL_CreateWindow
(
"one_armed_bandit"
,
SDL_WINDOWPOS_UNDEFINED
,
...
@@ -33,16 +30,12 @@ SDL_Window* init_display(){
...
@@ -33,16 +30,12 @@ SDL_Window* init_display(){
}
}
void
display_wheel
(
int
pixel
,
int
offset
){
void
display_wheel
(
int
pixel
,
int
offset
){
// -------------------------
// example of board display:
// -------------------------
SDL_Rect
src_rect
,
dst_rect
=
object_rect
;
SDL_Rect
src_rect
,
dst_rect
=
object_rect
;
dst_rect
.
h
=
object_height
*
1
.
5
;
// display 1.5 object on screen for a wheel
dst_rect
.
h
=
object_height
*
1
.
5
;
// display 1.5 object on screen for a wheel
src_rect
=
dst_rect
;
src_rect
=
dst_rect
;
src_rect
.
x
=
0
;
src_rect
.
x
=
0
;
// src_rect.y is positionned here on the 2nd object of objects.png
// src_rect.y is positionned here on the 2nd object of objects.png
//85 + index*104 + 1
src_rect
.
y
=
offset
;
src_rect
.
y
=
offset
;
dst_rect
.
x
=
pixel
;
dst_rect
.
x
=
pixel
;
dst_rect
.
y
=
410
-
object_height
/
2
;
// setup the coord. of the icon in the global renderer
dst_rect
.
y
=
410
-
object_height
/
2
;
// setup the coord. of the icon in the global renderer
...
...
This diff is collapsed.
Click to expand it.
one_armed_bandit.c
+
11
−
1
View file @
332f87b1
...
@@ -27,6 +27,16 @@ int how_many_points(machine mas){
...
@@ -27,6 +27,16 @@ int how_many_points(machine mas){
return
count
;
return
count
;
}
}
int
stopped_wheels
(
machine
mas
){
int
res
=
0
;
for
(
int
i
=
0
;
i
<
WHEEL_NB
;
i
++
){
if
(
mas
.
wheels
[
i
].
speed
==
0
){
res
+=
1
;
}
}
return
res
;
}
int
main
()
int
main
()
{
{
...
@@ -88,7 +98,7 @@ int main()
...
@@ -88,7 +98,7 @@ int main()
break
;
break
;
case
SDLK_s
:
case
SDLK_s
:
wait_key_release
();
wait_key_release
();
if
(
mas
.
player_wallet
>
0
){
if
(
mas
.
player_wallet
>
0
&&
stopped_wheels
(
mas
)
>
0
){
paid
=
false
;
paid
=
false
;
mas
.
player_wallet
-=
1
;
mas
.
player_wallet
-=
1
;
mas
.
machine_wallet
+=
1
;
mas
.
machine_wallet
+=
1
;
...
...
This diff is collapsed.
Click to expand it.
one_armed_bandit.h
+
4
−
1
View file @
332f87b1
...
@@ -19,5 +19,8 @@
...
@@ -19,5 +19,8 @@
\#/
\#/
*/
*/
int
how_many_points
(
machine
mas
);
// returns the score based on the positionning of the wheels
// returns the score based on the positionning of the wheels
int
how_many_points
(
machine
mas
);
int
stopped_wheels
(
machine
mas
);
\ No newline at end of file
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