The turn()
function rotates Gizmo in the specified direction. This function consumes energy to perform the action.
success = turn(direction)
direction
: An integer representing the direction to turn. Use the TurnDirectionEnum
:
The function returns a boolean:
True
if the turn was successful.False
if the turn failed (e.g., due to insufficient energy).Here's an example of how to use the turn()
function:
# Turn Gizmo to the right
success = turn(TurnDirectionEnum.Right)
if success:
print("Gizmo successfully turned right!")
else:
print("Gizmo couldn't turn right. There might be insufficient energy.")
# Make Gizmo do a full 360-degree turn
for _ in range(4):
if turn(TurnDirectionEnum.Left):
print("Turned left successfully")
else:
print("Failed to turn left")
break
This example demonstrates how to turn Gizmo in a specific direction and how to perform a series of turns.
turn()
function becomes available at level 1 (UnlocksAtLevel: 1).turn()
with move()
allows for more complex navigation patterns.