diff --git a/display.c b/display.c
index 9f70dedb12fd78e35a637fd521ea69bdbfa54a93..e3da824f6c40fa2f868edeca241cda6d4055a6b2 100644
--- a/display.c
+++ b/display.c
@@ -64,7 +64,12 @@ void *display_func(void *param){
 
 		SDL_Rect coin_rect_pos={700, 1020, coin_rect.w, coin_rect.h};
 		SDL_RenderCopy(renderer, coin_texture, NULL, &coin_rect_pos);
-		for (int i=0; i<4; i++){
+
+		for (int i=0; i<mas->machine_wallet; i++){
+			SDL_Rect coin_rect_pos={700, 1010-10*i, coin_rect.w, coin_rect.h};
+			SDL_RenderCopy(renderer, coin_texture, NULL, &coin_rect_pos);
+		}
+		for (int i=0; i<mas->player_wallet; i++){
 			SDL_Rect coin_rect_pos={700, 400-10*i, coin_rect.w, coin_rect.h};
 			SDL_RenderCopy(renderer, coin_texture, NULL, &coin_rect_pos);
 		}
diff --git a/game.c b/game.c
index acc79dd40a7052d604be37f2ffef397138d214da..a5fa54b14662a000c9bf3decc4560e8285f13b6a 100644
--- a/game.c
+++ b/game.c
@@ -23,8 +23,10 @@ wheel create_wheel(int pixel,int speed){
 
 }
 
-void new_machine(machine* mas, int nb_wheels){
+void new_machine(machine* mas, int nb_wheels,int player, int machine){
   for (int i = 0; i < nb_wheels; i++) {
-    mas->wheels[i] = create_wheel(96,nb_wheels-i);
+    mas->wheels[i] = create_wheel(96,0);
+	mas->player_wallet = player;
+	mas->machine_wallet = machine;
   }
 }
diff --git a/game.h b/game.h
index 95b2ba64140fdc2078616cbd325ffd0ab92dd881..a61cec6d4362c9a5ea776672d6c70e32618898dc 100644
--- a/game.h
+++ b/game.h
@@ -21,6 +21,6 @@ int insert_coin();
 int set_wheel_speed(int index);
 int next_wheel();
 wheel create_wheel(int pixel,int speed);
-void new_machine(machine* mas, int nb_wheels);
+void new_machine(machine* mas, int nb_wheels,int player, int machine);
 
 #endif
diff --git a/one_armed_bandit.c b/one_armed_bandit.c
index 5cacb927df6f77d8ac76f231eb6721454aea6a89..d24a9bc7b0695e01cd7a40a0a0412db97f386f8e 100644
--- a/one_armed_bandit.c
+++ b/one_armed_bandit.c
@@ -17,13 +17,26 @@
 
 
 
+int how_many_points(machine mas){
+	int count = 0;
+	int bubble = mas.wheels[0].current_px;
+	for(int i =0; i<WHEEL_NB; i++){
+		if(bubble == mas.wheels[i].current_px) count += 1;
+	}
+	if(mas.wheels[1].current_px == mas.wheels[2].current_px) count += 1;
+
+	return count;
+}
+
+
 int main()
 {
-	int wheel_turn = 0;
+	int wheel_turn = 4;
+	bool paid = false;
 	pthread_t threads[4];
 
 	machine mas;
-	new_machine(&mas, 3);
+	new_machine(&mas, 3,10,30);
 	
 	for(int i = 0; i<3; i++){
 		run_thread(&threads[i],wheel_func,&mas.wheels[i]);
@@ -59,16 +72,33 @@ int main()
 							break;
 						case SDLK_SPACE:
 							wait_key_release();
-							if(wheel_turn <3){
+							if(wheel_turn <WHEEL_NB){
 								stop_wheel(&mas.wheels[wheel_turn]);
 								wheel_turn += 1;
 							}
+							if(wheel_turn == WHEEL_NB && paid == false){
+								paid = true;
+								int howmany = how_many_points(mas);
+								if(howmany == 2){
+									mas.player_wallet += 2;
+									mas.machine_wallet -= 2;
+								}
+								else if(howmany > 2){
+									mas.player_wallet += mas.machine_wallet/2;
+									mas.machine_wallet -= mas.machine_wallet/2;
+								}
+							}
 							break;
 						case SDLK_s:
 							wait_key_release();
-							wheel_turn =0;
-							for(int i = 0; i<3; i++){
-								mas.wheels[i].speed = 3-i;
+							if(mas.player_wallet > 0){
+								paid = false;
+								mas.player_wallet -= 1;
+								mas.machine_wallet += 1;
+								wheel_turn =0;
+								for(int i = 0; i<WHEEL_NB; i++){
+									mas.wheels[i].speed = WHEEL_NB-i;
+								}
 							}
 							break;
 				}
diff --git a/utilities.c b/utilities.c
index 091520bd6c4b3066ce7ba082fb85519a276e419e..650144b170ef4ef8dec2d44d70c93afd69d62003 100644
--- a/utilities.c
+++ b/utilities.c
@@ -64,7 +64,7 @@ void wait_key_release()
         if (SDL_PollEvent(&event)) {
             if (event.type==SDL_KEYUP)
             {
-                printf("key released\n");
+                //printf("key released\n");
                 break;
             }
         }
diff --git a/wheel.c b/wheel.c
index 944a536006c46a7e66e593bffec0ab7f447a9bfe..1055717aed9b899ef0db9dc96745c2b2cb5e30ae 100644
--- a/wheel.c
+++ b/wheel.c
@@ -38,8 +38,8 @@ int wheel_delay_ms(wheel this){
 }
 
 int stop_wheel(wheel* this){
-  while (this->current_px % 128 != 128-32) { // 32 is the offset to center the item
-    wheel_spin_1_tick(this);
+  while (this->current_px % 128 != 96) { // 32 is the offset to center the item
+    //wheel_spin_1_tick(this);
     wait_until(wheel_delay_ms(*this));
   }
   this->speed = 0;