Graphical programming and entertainment in teaching, Kittenblock example, modify the pen color

Like many students talked to a lot of students are not hard, but could not find the feeling. One thing is undeniable, the same class in a classroom, a teacher is also teaching, learning different. The key question is, bring a sense of advice I can give is to bite the bullet, hold on, no knowledge will not. We will continue to share experiences of graphical programming, hoping to make a topic. If you find useful, give a point like it. Software covered include scratch3.0 (.sb3), Python, Kittenblock.

Reading program: modified pen color

Knowledge Point: Brush, control, event, appearance, shape adjustment, detection

Software involved: scratch3.0 (.sb3), Python, Kittenblock.

 

# -*- coding: utf-8 -*-

import _env, time, random

from kblock import *

Brush = Sprite ( "brush")

Modify Color = Sprite ( "Modify Color")

 

x = 0

 

 

Brush .looks_gotofrontback ( "front")

Brush .looks_switchcostumeto ( "pencil-b")

Brush .pen_clear ()

Brush .pen_setPenColorToColor ( "# FF0000")

Brush .pen_setPenSizeTo (8)

while True:

  Brush .motion_goto ( "_ mouse_")

  if the brush .sensing_mousedown ():

    Brush .pen_penDown ()

  else:

    Brush .pen_penUp ()

  if the brush .sensing_touchingobject ( "Modify Color"):

    Brush .pen_setPenColorToColor ( "# 00ff59")

Brush .pen_setPenSizeTo (1)

 

Process map!

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/ztg1/p/12558220.html