Skip to content
Snippets Groups Projects
Commit 332f87b1 authored by benjamin.sitbon's avatar benjamin.sitbon
Browse files

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
...@@ -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
......
...@@ -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;
......
...@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment