Hello, friends , I believe most people like playing games , Whether it's between work or on the way home from work , May pick up the phone to play games to pass the time , Or find fun in the game , Relax yourself . upper

What I share with you is mainly Python of Pygame
Zero Module to make small games , Programming environment is also recommended :Thonny( Open source cross platform ).Thonny Is a cross platform open source development environment , Bring your own Python interpreter , Small size , Fully functional . Scan the following QR code , A teacher will teach you how to install it Thonny And Application Thonny. 

Thonny After installation , conduct Pygame Zero Module installation . First open Thonny, Click menu “ tool ”->“ Management module ”, input “pgzero”
Click search , Last click “install” , Installation succeeded !

We made an elf , After asking to click on the elf , Will make a sound and the spirit will fall . The first step is to create a game character :

• Create two new directories under the source code file directory : One is images( Name can be customized ), Used to store picture files ; The other is sounds, Used to store sound files .

• use Actor Class to create a sprite object : Specify picture , position

• stay draw Draw a spirit in the picture : The sprite image will appear in the specified location alien.pos

Step 2 Update update: Change the position of the sprite , It changes every second 60 second !
import pgzrun import time # Create a sprite alien = Actor('alien') alien.pos = 100,56
# Draw window size WIDTH = 500 HEIGHT = alien.height + 100 # Every time you need to refresh the window , Automatically called draw function
def draw():     screen.clear()     screen.fill((128, 0, 0))     alien.draw()
Called every frame update function def update():     alien.left += 2     if alien.left > WIDTH:
        alien.left = 0

  Step 3 interaction with elves :pos Is the position of the mouse , When clicking on the wizard , The Elves will fall , And send “ Uh ” Sound of ,1s Restore the initial state after ; If you don't click on the wizard , Will print out “ flash ” Two words ; If there is no click behavior , The spirit will keep moving in a circle .
def on_mouse_down(pos):     if alien.collidepoint(pos):
        set_alien_hurt()     else:         print(" flash ")         
def set_alien_hurt():         sounds.eep.play()
        alien.image = 'alien_hurt'         print(" Uh ")
        clock.schedule_unique(set_alien_normal, 1.0)         
def set_alien_normal():     alien.image = 'alien' pgzrun.go()
    
It's done here ! The above is a small example , Let's get to know each other for the first time Python of Pygame Zero modular , You can use it in your spare time Python Let's play games , On the one hand, it can consolidate relevant knowledge , On the other hand, it can broaden vision and release pressure .

Previous reference answer

program :
from turtle import * from random import * from math import *   def tree(n, l):
    pd()      pencolor('brown')     pensize(n / 3)     forward(l)     
    if n > 0:         b = random() * 15 + 10          c = random() * 15 + 10 
        d = l * (random() * 0.25 + 0.7)          right(b)
        tree(n - 1, d)         left(b + c)         tree(n - 1, d)
        right(c)     else:         right(90)         pencolor('green')
        circle(3)         left(90)              pu()     backward(l) ht()
speed(0)  tracer(0) pu()  backward(100) left(90)  pu() backward(300)
tree(12, 100) done()    
result :

I'd like to recommend it here Python study Q group :831804576, The group is full of students Python of , If you want to learn or are learning Python
, Welcome to join us , Everyone is a software development party , Share dry goods irregularly ( only Python Software development related ),
Including one I sorted out myself 2022 abreast of the times Python Advanced materials and zero basic teaching , Welcome to advanced neutralization Python Interested partners join !

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage MySQL Basics Commonly used sentence ( Add / delete / modify query )C Language of a Gobang game implementation QT5.9 Use of learning notes QSqlQuery Method of Qt Getting Started tutorial 【 Basic controls 】QCalendarWidget calendar control java Polymorphic array of web Front end signature plug-in _signature_pad Plug in implements electronic signature function centos7 install RabbitMqspringboot use redis Experiment 4 Automated test tools - software test