|
|
@@ -9,6 +9,7 @@ import dobluetooth
|
|
|
import math
|
|
|
import pygame
|
|
|
|
|
|
+
|
|
|
# Initialize pygame and mixer specifically for MP3
|
|
|
pygame.init()
|
|
|
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.geometry("1440x1024")
|
|
|
+app.title("Punching Game")
|
|
|
|
|
|
canvas = ctk.CTkCanvas(app, width=250, height=250, highlightthickness=0)
|
|
|
canvas.config(background="white")
|
|
|
@@ -110,7 +112,8 @@ def stopPunch():
|
|
|
update_dinger_position(currentScore.get())
|
|
|
if stop_sound:
|
|
|
try:
|
|
|
- stop_sound.play()
|
|
|
+ if 100.0<=currentScore.get():
|
|
|
+ stop_sound.play()
|
|
|
except Exception as e:
|
|
|
print(f"Error playing sound: {str(e)}")
|
|
|
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
|
|
|
print(value)
|
|
|
- if(value < 0.26):
|
|
|
+ if(value < 0.4):
|
|
|
pass
|
|
|
else:
|
|
|
+ if(value * 100 > currentScore.get()):
|
|
|
+ app.after(0, lambda val=value: currentScore.set(int(value*100)))
|
|
|
+ """
|
|
|
if(last_value - value > 10.00):
|
|
|
app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val)))
|
|
|
else:
|
|
|
@@ -303,6 +309,7 @@ def data_loop():
|
|
|
app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val)))
|
|
|
else:
|
|
|
app.after(0, lambda val=value: currentScore.set(currentScore.get() + int(val*25)))
|
|
|
+ """
|
|
|
|
|
|
app.after(0, update_dinger_position)
|
|
|
last_data = bledata
|