Python controls the stage role

By using Python to manipulate the stage character, you can achieve the same effect as using the Scratch block, you can:

  • Learn Python based on Scratch;

  • It is more convenient to write a code of a certain size than dragging and dropping a statement block, such as implementing an algorithm;

Start using Python

Click on the Python flag in the upper right corner to switch to the Python programming area.

Program block conversion to Python

Dragging a block will generate the corresponding Python code

Mobile wizard

move\ (distance)

sprite.move(10)

right(angle)

sprite.right(15)

left(angle)

sprite.left(15)

direction(angle)

sprite.direction(105)

Position and coordinates

Move the character to the specified x,y coordinates on the screen

#Move to the (10,10) coordinates
sprite.gotoxy(10,10)

Move the character to the specified location on the screen

# Move to random location
sprite.moveto('random')

#Move to the mouse
sprite.moveto('mouse')

Let the character slide to the specified x,y coordinates on the screen within the specified time to allow the character to slide to the specified x,y coordinates on the screen within the specified time.

#Slide to (9, -110) coordinates within 1 second
sprite.glide(9,-110,1)

Let the character slide to the specified position on the screen within the specified time

#Swipe to random position within 1 second
sprite.glideto('random',1)

#Swipe to the mouse within 1 second
sprite.glideto('mouse',1)

Role appearance

Let the character "speak" or "think" the specified text on the screen

#Disappears after 2 seconds
sprite.say('Hello!',2)

#Always show
sprite.say('Hello!')
#Disappears after 2 seconds
sprite.think('Hmm...',2)
Always show
sprite.think('Hmm...')

"Show" and "Hide" of the character

#Show
sprite.show()

#Hide
sprite.hide()