Move

Description

The move() function makes Gizmo travel in a specified direction. This function consumes energy and returns false if the movement fails.

Syntax

success = move(direction)

Parameters

  • direction: An integer representing the direction to move. Use the MoveDirectionEnum:
    • 0: Forward
    • 1: Backward

Return

The function returns a boolean:

  • True if the movement was successful.
  • False if the movement failed (e.g., due to an obstacle or insufficient energy).

Examples

Here's an example of how to use the move() function:

# Try to move Gizmo forward
success = move(MoveDirectionEnum.Forward)

if success:
    print("Gizmo successfully moved forward!")
else:
    print("Gizmo couldn't move forward. There might be an obstacle or insufficient energy.")

# Move Gizmo in a square pattern
for direction in [MoveDirectionEnum.Forward, MoveDirectionEnum.Backward]:
    if move(direction):
        print(f"Moved successfully in direction: {direction}")
    else:
        print(f"Failed to move in direction: {direction}")

This example shows how to move Gizmo forward and how to create a simple pattern of movements.

Notes

  • The move() function is available from the start of the game (UnlocksAtLevel: 0).
  • Movement consumes energy. Make sure to check energy levels regularly.
  • Always check the return value to ensure the movement was successful.
  • The function will fail if there's an obstacle in the way or if Gizmo doesn't have enough energy.