Table of Contents

Beetle Movement – Python

Example Description
The example demonstrates using key sensing to control the sprite's movement in Python.

Code

sprite = Sprite('Beetle')

sprite.setdirection(90)
sprite.gotoxy(0, 0)

while True:
  if sprite.iskeypressed('up arrow'):
    sprite.move(3)
  if sprite.iskeypressed('down arrow'):
    sprite.move(-3)
  if sprite.iskeypressed('left arrow'):
    sprite.left(3)
  if sprite.iskeypressed('right arrow'):
    sprite.right(3)

Output