How to learn Python at KittenBlock

  • Dear all,

    We’re very proud to announce that you’re able to using Python to program and control the spite on the stage within Scratch 3.0 offline editor. And yes, we’re the first team in the world to make this happen.

    Before you try the amazing function, please make sure you’ve installed the lastest KittenBlock V1.6. (2017, Dec 27th)

    Download here:

    Windows | MAC OS

    We’ve refactored the Python library for Scratch 3.0 to support programming with multiple sprites and basically all of the functionality that graphical programming can do.

    Fun python function does not require any hardware, and through python code to achieve more than the previous graphical more complex functions. Let’s work together to write a Python Hello World program. code show as below:

    The first line: import First load the scratch3 library, which is the core of the stage interaction.
    The second line: Instantiate a wizard entity, the name of the wizard can be seen in the wizard properties box below the stage.
    The third line: let the kitty say HelloPython, the code is written, we can click on the run button on the right side of the Python code panel If all goes well, we can see:

    Your first python program will be up and running. Now let’s take a look at the Python APIs for Kittenblock.
    Currently python implements the following four categories of functions, namely motion, looks, sound, pen

    Just import the Python code header and instantiate a sprite entity

    You can use the corresponding library function, as for other logic loop variables and mathematical calculations are used python native; Then look at the use of the corresponding API:

    Motion Part

    cat. move (10) # let the sprite move 10 steps

    cat.gotoXY(100,100) # let the sprite move to coordinate x100, y100

    cat.turnLeft(90) # let the sprite turn left 90 degree

    cat.turnRight(90) # let the sprite turn right 90 degree

    cat.direction(180) #let the sprite point to 180 degree

    cat.glideXY(100,100,sec=5) # let the sprite slip to 100,100 within 5 seconds

    cat.changeX(10) # Change the X Position

    cat.changeY(10) # Change the Y Position

    cat.setX(10) # Set the X Position

    cat.setY(10) # Set the Y Position

    cat.xPosition() # Return the X Position

    cat.yPosition() #Return the Y Position

    cat.direction() #Return the sprite direction

    Look Part

    cat.say(“hello world”) #let sprite say some words #show off the sprite

    cat.hide() #hide the sprite

    cat.switchCostume(“custome1”) #change the skin of sprite

    cat.switchBackground(“background”) #change the background of stage

    cat.nextCustome() #switch to the next skin

    cat.nextnetBackground() #switch to the next background

    #Sound Part“meow”) #play the sound of sprite

    cat.stopALL() #stop all the sound

    cat.playDrum(1,0.25) #play drumming, the first parameter corresponds to the type of drum can go to the corresponding tile view, the second parameter is the tempo length #stop the tempo

    cat.playNote(60,0.5) #play the notes, the second parameter is the tempo length

    cat.setInstrument(2) #set the type of instrument

    cat.changeEffect(1,10) #exchange effect of sound

    cat.setSoundEffect(1,10) #set effect of sound

    cat.clearSoundEffect(1,10) #clear effect of sound

    cat.changeVolume(10) #exchange the volume of sound

    cat.setVolume(100) #set the volume of sound

    cat.volume() #read the volume of sound

    cat.changeTempo() #change the tempo of sound

    cat.setTempo() #set the tempo of sound

    cat.tempo() #return to the tempo

    #Pen Part
    car.clear() #clear the current image

    cat.stamp() #use the current sprite stamp

    cat.penDown() #down the pen

    cat.penUp() #up the pen

    cat.setColor(“#ff0000”) #set the color of the pen

    cat.changeColor(10) #change the color’s HUE value

    cat.setShade(10) #change the shade of pen

    cat.penSize(10) #set the size of pen

    cat.changePenSize(1) #change the size of pen

    Thank you all guys for supporting KittenBot team since last year, please let us know if you need more interesting functions and we’re trying our best to improve the KittenBlock user experience!

    Keep in touch!

    KittenBot Team