Table of Contents

right()

Function Definition: right(angle = 15)

Parameters

NameTypeDescriptionExpected ValuesDefault Value
angleintThe angle by which the rotation needs to be executedinterger15

Description

The function turns the sprite by the specified amount of degrees clockwise. This changes the direction the sprite is facing.

Example

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

Read More
The example demonstrates the sprite direction in Python.

Code

sprite = Sprite('Arrow1')

sprite.gotoxy(0, 0)
sprite.setsize(300)

while True:
  if sprite.iskeypressed("left arrow"):
    sprite.left(3)
  if sprite.iskeypressed("right arrow"):
    sprite.right(3)
  sprite.say("Direction is " + str(sprite.direction()))

Output

Read More
All articles loaded
No more articles to load