Browse Source

final changes

Lucas 7 months ago
parent
commit
05ee4ed056
2 changed files with 9 additions and 3 deletions
  1. 9 2
      GUI.py
  2. 0 1
      all_scores.txt

+ 9 - 2
GUI.py

@@ -9,6 +9,7 @@ import dobluetooth
 import math
 import math
 import pygame
 import pygame
 
 
+
 # Initialize pygame and mixer specifically for MP3
 # Initialize pygame and mixer specifically for MP3
 pygame.init()
 pygame.init()
 pygame.mixer.init(frequency=44100, size=-16, channels=2, buffer=2048)
 pygame.mixer.init(frequency=44100, size=-16, channels=2, buffer=2048)
@@ -33,6 +34,7 @@ ctk.set_default_color_theme("blue")
 
 
 app = ctk.CTk()
 app = ctk.CTk()
 app.geometry("1440x1024")
 app.geometry("1440x1024")
+app.title("Punching Game")
 
 
 canvas = ctk.CTkCanvas(app, width=250, height=250, highlightthickness=0)
 canvas = ctk.CTkCanvas(app, width=250, height=250, highlightthickness=0)
 canvas.config(background="white")
 canvas.config(background="white")
@@ -110,7 +112,8 @@ def stopPunch():
     update_dinger_position(currentScore.get())
     update_dinger_position(currentScore.get())
     if stop_sound:
     if stop_sound:
         try:
         try:
-            stop_sound.play()
+            if 100.0<=currentScore.get():
+                stop_sound.play()
         except Exception as e:
         except Exception as e:
             print(f"Error playing sound: {str(e)}")
             print(f"Error playing sound: {str(e)}")
     print("STOPPED PUNCH")
     print("STOPPED PUNCH")
@@ -290,9 +293,12 @@ def data_loop():
 
 
             value = math.sqrt((current_x_accel - last_y_accel)**2 + ((current_y_accel - last_y_accel)**2))/4
             value = math.sqrt((current_x_accel - last_y_accel)**2 + ((current_y_accel - last_y_accel)**2))/4
             print(value)
             print(value)
-            if(value < 0.26):
+            if(value < 0.4):
                 pass
                 pass
             else:
             else:
+                if(value * 100 > currentScore.get()):
+                    app.after(0, lambda val=value: currentScore.set(int(value*100)))
+                """
                 if(last_value - value > 10.00):
                 if(last_value - value > 10.00):
                     app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val)))
                     app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val)))
                 else:
                 else:
@@ -303,6 +309,7 @@ def data_loop():
                             app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val)))
                             app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val)))
                     else:
                     else:
                         app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val*25)))
                         app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val*25)))
+                """
 
 
             app.after(0, update_dinger_position)
             app.after(0, update_dinger_position)
             last_data = bledata
             last_data = bledata

+ 0 - 1
all_scores.txt

@@ -1 +0,0 @@
-