Graphical programming, entertainment and teaching, Kittenblock scratch examples, shape switching, mouse detection

I have talked to many students, many students are not hard, but just can not find the feeling. It is undeniable that the same class is taught in the same classroom, and the teaching effect is also very different. The key problem is that the sense of substitution, the advice I can give, is to gritt your teeth, hold on, and have no knowledge you cannot learn.

 

Will continue to share the experience of graphical programming, hoping to make a topic. If you find it useful, please give it a thumbs up. Interpretation of the program: mouse press, shooting effect (shape switching, mouse detection)

Knowledge points: modeling, detection, selection, control, broadcasting

Involved software: scratch3.0 (.sb3) , Python , Kittenblock .

 

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

import _env, time, random

from kblock import *

Fort = Sprite (" Fort ")

Character 1 = Sprite (" Character 1")

 

x = 0

Fire = 0

 

 

# Set gun shape on top, initialization modeling

Role 1.looks_gotofrontback ()

角色1.looks_switchcostumeto("Magicwand")

# Position initialization gun

Role 1.motion_gotoxy (0, 0)

                                          # Circulation effect, the mouse pointer for the gun

while True:

  Character 1.motion_pointtowards ("_ mouse_")

              # Detection judgment, if the mouse is pressed, the switching modeling delay 0.2 seconds

  if role 1.sensing_mousedown ():

    角色1.looks_switchcostumeto("Magicwand2")

    time.sleep(0.2)

    角色1.looks_switchcostumeto("Magicwand")

    # Broadcast messages opened fire, delayed 0.1

    Role 1.event_broadcast ("] 1IK [LKV, j * jxh3}?-QG")

    time.sleep(0.1)

Process diagram!

 

 

 

 

 

 

Programming thinking is a very logical thinking mode, which is beneficial to the growth of everyone. However, in the face of sentences, many students have difficulty switching their thinking mode to the state of computer programming. I think learning programming starts with reading the program. The biggest advantage of graphical programming is that we can switch our thinking between graphics and code.

Guess you like

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