Table of Contents

Ball Movement – Python

Example Description
The example demonstrates how to add movement to a sprite.

Code

sprite = Sprite('Ball')

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