Share an interesting day Python Game library freegames, It contains 20 Remaining classic games , Like a greedy snake , Pac Man , Table tennis , Digital Huarong Road, etc , Relying on standard library Turtle.

We can not only pass 1 Line of code to revisit these childhood games , You can also view the source code and learn to write the game yourself , Great !

# 1. install

adopt pip Simple installation , The latest version is 2.3.2
pip install freegames

# 2. Basic introduction

After installation , We can view the relevant information through the following instructions
#  View the list of existing games !python -m freegames list #  stay jupyter notebook
python -m freegames list #  In the command line interface

View the list of existing games
#  view help help(freegames) #  It can also be used  ?  stay jupyter notebook import freegames freegames?

view help

# 3. Game demo

Here we introduce several familiar games , And demonstrate

Paint Graffiti   Draw lines and shapes on the screen

Click to mark the beginning of the shape , Then click again to mark its end ;

You can use the keyboard to select different shapes and colors .
!python -m freegames.paint #  If on the command line , Then remove the front   exclamatory mark  !


Snake Greedy snake   Classic arcade games

Use the keyboard's arrow keys to navigate and eat green food , Every time you eat food , The snake will grow for a while ;

Avoid eating yourself or crossing the line .
!python -m freegames.snake

Greedy snake

Pacman Pac Man   Classic arcade games

Use the arrow keys to navigate and eat all the white food ;

Beware of the red ghost roaming the maze , I knelt when I met him .
!python -m freegames.pacman

Pac Man

Cannon artillery

Click on the screen to fire your cannon , The shell blew up the blue balloon in its path ;

Blow up all the balloons before they cross the screen .
!python -m freegames.cannon


Flappy Flappy-bird Class game

Click on the screen to flap your wings ;

When you fly across the screen , Please be careful not to touch the black crow .

Flappy Bird

Pong Table tennis   Classic arcade games

Use the keyboard to move the racket up and down , The first player who missed the ball lost
!python -m freegames.pong

Table Tennis

Tiles Digital Huarong Road   A puzzle game that slides numbers to a specified position

Click the block adjacent to the empty square to swap positions , You can make the numbers from left to right and from bottom to top 1 reach 15 Do you ?
!python -m freegames.tiles

Digital Huarong Road

There are more games , You can experience it yourself , If you are interested, you can also study the source code and learn how to write it python Games !

# 4. Source view

adopt copy Relevant source files can be copied locally , Then check the source code , We can learn according to the source code !
!python -m freegames copy snake

snake Source file Preview

The above is the whole content of this time , Interested partners can install this library to play with , By the way, learn to write a little game by yourself !

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 !

©2019-2020 Toolsou All rights reserved,
【C++ Must see for entry 】C++ from 0 reach 1 Introductory programming axios Interceptor packaging and use Spring Boot Interview must ask : Automatic configuration principle VMware 16 install centos 7 Detailed tutorial C Language data structure - Sequence table delete duplicates V2.0.0 The 12th Blue Bridge Cup c++b Group personal problem solving On sending data from serial port single chip microcomputer to upper computer centos7 install RabbitMqjava Polymorphic array of opencv-python Fourier transform and inverse transform