Funktionalität beim Rotationssensor: wenn eine falsche Richtung ausgewählt wird -> Game over

This commit is contained in:
Franziska Gerold 2025-12-19 05:04:04 +11:00
parent 50633ed4f7
commit 237a13924b

View File

@ -39,23 +39,19 @@ def command_scream():
else:
return -1
def command_spin_clockwise():
print("Spin me... clockwise!")
result = rotate.wait_for_rotate_clockwise(timeout=10)
if result:
def command_spin():
directions = ["clockwise", "counter-clockwise"]
used_direction = random.choice(directions)
print(f"Spin me... {used_direction}!")
rotate.value = 0 # damit jede Runde wieder bei Null anfängt, Werte würden allgemein vom -1 bis 1 reichen
result = rotate.wait_for_rotate(timeout=10)
if result > 0 and used_direction == "clockwise" or result < 0 and used_direction == "counter-clockwise":
print(success_message())
return 1
else:
print("You waited too long or used the wrong direction!")
return -1
def command_spin_counter_clockwise():
print("Spin me... counter clockwise!")
result = rotate.wait_for_rotate_counter_clockwise(timeout=10)
if result:
print(success_message())
return 1
else:
return -1
def success_message():
list_of_messages = ["Great job!", "Correct!", "Nice!", "You know it!", "That's what I'm talking about", "Perfect!"]
@ -69,9 +65,9 @@ def main():
print("Every correct action will give you a point.")
print("How many can you get?")
print("Let's go!")
list_command_choices =[command_tilt, command_spin_clockwise, command_spin_counter_clockwise, command_blind, command_scream]
list_command_choices =[command_tilt, command_spin, command_blind, command_scream]
while result != -1:
score += result # war zuerst zwei Zeilen weiter unten, hat dann aber nach einer falschen Runde den Score erhöht
score += result # war zuerst ein paar Zeilen weiter unten, hat dann aber nach einer falschen Runde den Score erhöht
time.sleep(0.5)
print("Get ready for the next round!")
round = random.choice(list_command_choices)