|
|
@@ -61,14 +61,14 @@ def move_dinger_step(start_y, target_y, steps_left, total_steps):
|
|
|
if steps_left > 0:
|
|
|
# Calculate progress (0 to 1)
|
|
|
progress = (total_steps - steps_left) / total_steps
|
|
|
-
|
|
|
+
|
|
|
# Calculate the current position directly between start and target
|
|
|
new_y = start_y + (target_y - start_y) * progress
|
|
|
-
|
|
|
+
|
|
|
# Update position
|
|
|
current_dinger_y = new_y
|
|
|
dinger.place_configure(y=int(new_y))
|
|
|
-
|
|
|
+
|
|
|
# Schedule next step
|
|
|
app.after(10, lambda: move_dinger_step(start_y, target_y, steps_left - 1, total_steps))
|
|
|
else:
|
|
|
@@ -79,7 +79,7 @@ def move_dinger_step(start_y, target_y, steps_left, total_steps):
|
|
|
def update_dinger_position(final_score=None):
|
|
|
global current_dinger_y
|
|
|
start_y = current_dinger_y # Remember where we're starting from
|
|
|
-
|
|
|
+
|
|
|
if final_score is None:
|
|
|
target_y = 900 # Bottom position
|
|
|
else:
|
|
|
@@ -92,7 +92,7 @@ def update_dinger_position(final_score=None):
|
|
|
movement = min(movement, max_movement)
|
|
|
target_y = 900 - movement # Calculate from top position
|
|
|
target_y = max(100, min(target_y, 900)) # Ensure within bounds
|
|
|
-
|
|
|
+
|
|
|
# Start the animation
|
|
|
move_dinger_step(start_y, target_y, 60, 60)
|
|
|
|
|
|
@@ -101,6 +101,7 @@ def startPunch():
|
|
|
punch_on = True
|
|
|
updateStatusLabel()
|
|
|
update_dinger_position()
|
|
|
+ print("STARTED PUNCH")
|
|
|
|
|
|
def stopPunch():
|
|
|
global punch_on
|
|
|
@@ -112,6 +113,7 @@ def stopPunch():
|
|
|
stop_sound.play()
|
|
|
except Exception as e:
|
|
|
print(f"Error playing sound: {str(e)}")
|
|
|
+ print("STOPPED PUNCH")
|
|
|
|
|
|
def resetPunch():
|
|
|
global currentScore
|
|
|
@@ -161,17 +163,17 @@ def submitScore():
|
|
|
current_score = currentScore.get()
|
|
|
names.append(entered_name)
|
|
|
scores.append(current_score)
|
|
|
-
|
|
|
+
|
|
|
# Save the new score to file
|
|
|
save_new_score(entered_name, current_score)
|
|
|
-
|
|
|
+
|
|
|
if current_score > highestScore:
|
|
|
highestScore = current_score
|
|
|
highScoreName = entered_name
|
|
|
|
|
|
# Clear the entry field after recording
|
|
|
nameEntry.delete(0, 'end')
|
|
|
-
|
|
|
+
|
|
|
# Refresh the leaderboard display
|
|
|
placeLeaderboard()
|
|
|
|
|
|
@@ -186,7 +188,7 @@ def placeLeaderboard():
|
|
|
top_5_pairs = score_pairs[:5]
|
|
|
|
|
|
intx = 0
|
|
|
- inty = 60
|
|
|
+ inty = 100
|
|
|
for name, score in top_5_pairs:
|
|
|
label1 = ctk.CTkLabel(width=124, height=39, text_color="white", text=name, font=("Arial", 15), master=app)
|
|
|
label1.place(x=intx, y=inty)
|
|
|
@@ -194,8 +196,8 @@ def placeLeaderboard():
|
|
|
label2.place(x=intx + 125, y=inty)
|
|
|
inty += 40
|
|
|
|
|
|
- ctk.CTkLabel(width=249, height=39, text_color="white", text="Leaderboard", font=("Arial", 50), master=app).place(x=0, y=0)
|
|
|
-
|
|
|
+ ctk.CTkLabel(width=200, height=30, text_color="white", text="Leaderboard", font=("Arial", 50), master=app).place(x=0, y=0)
|
|
|
+
|
|
|
# Create status indicator
|
|
|
statusLabel = ctk.CTkLabel(
|
|
|
master=app,
|
|
|
@@ -208,7 +210,7 @@ def placeLeaderboard():
|
|
|
font=("Arial", 16)
|
|
|
)
|
|
|
statusLabel.place(x=50, y=450)
|
|
|
-
|
|
|
+
|
|
|
ctk.CTkButton(master=app,
|
|
|
width=120,
|
|
|
height=80,
|
|
|
@@ -237,27 +239,27 @@ def placeLeaderboard():
|
|
|
font=("Arial", 30),
|
|
|
command=resetPunch).place(x=50, y=700)
|
|
|
|
|
|
- ctk.CTkLabel(width=50, height=20, text_color="white", text="Current Score", font=("Arial", 50), master=app).place(x=350, y=20)
|
|
|
- ctk.CTkLabel(width=50, height=20, text_color="white", textvariable=currentScore, font=("Arial", 50), master=app).place(x=500, y=100)
|
|
|
+ ctk.CTkLabel(width=50, height=20, text_color="white", text="Current Score", font=("Arial", 50), master=app).place(x=500, y=0)
|
|
|
+ ctk.CTkLabel(width=50, height=20, text_color="white", textvariable=currentScore, font=("Arial", 50), master=app).place(x=725, y=100)
|
|
|
|
|
|
nameEntry = ctk.CTkEntry(width=300, height=50, master=app, font=("Arial", 50))
|
|
|
- nameEntry.place(x=370, y=200)
|
|
|
+ nameEntry.place(x=500, y=200)
|
|
|
|
|
|
- enterButton = ctk.CTkButton(width=50, height=50, text="ENTER", fg_color="green", font=("Arial", 20),
|
|
|
+ enterButton = ctk.CTkButton(width=50, height=75, text="ENTER", fg_color="green", font=("Arial", 20),
|
|
|
text_color="gray99", master=app, command=submitScore)
|
|
|
- enterButton.place(x=670, y=205)
|
|
|
+ enterButton.place(x=825, y=205)
|
|
|
|
|
|
# Load and display the bell image
|
|
|
bell_image = Image.open("./BellDrawing.png")
|
|
|
photo = ImageTk.PhotoImage(bell_image)
|
|
|
image_label = ctk.CTkLabel(image=photo, text="", width=10, master=app)
|
|
|
image_label.image = photo # Keep a reference to prevent garbage collection
|
|
|
- image_label.place(x=800, y=0)
|
|
|
+ image_label.place(x=1000, y=0)
|
|
|
|
|
|
# Create the dinger after the image (so it appears on top)
|
|
|
dinger = ctk.CTkLabel(width=40, height=30, text="", fg_color="gray77", master=app)
|
|
|
- dinger.place(x=1005, y=900)
|
|
|
-
|
|
|
+ dinger.place(x=1205, y=900)
|
|
|
+
|
|
|
# Start updating dinger position
|
|
|
update_dinger_position()
|
|
|
|