Simple python programming games, use python to write small games

This article mainly introduces the simple python programming game, which has certain reference value. Friends who need it can refer to it. I hope that you will gain a lot after reading this article. Let the editor take you to understand it together.

Although everyone always teases that programmers have no hair, they look older than their actual age. But in fact, we are a group with a very childlike innocence. The locomotive collector AI pseudo-original . Today I will share a private GitHub project - free-python-games, one line of command can take you into a small game, let you experience the simple happiness of childhood!

The games here are all developed using Python. After learning Python for a period of time, many students also want to write a few small games to practice their hands, and send them to friends for a while. Those are good reference cases.

Project address: If necessary, you can scan the QR code of CSDN official certification below on WeChat to receive it for free

Installation and use

The installation is very simple, one line of code can be done:

pip install freegames

Since all games in this project are based on Python's built-in module Turtle, there are not many dependencies and installation will not be difficult.

After installation, we can use python -m freegames list to view all game lists
insert image description here

Snake

Now we can use one line of code to start related games, such as snake

python -m freegames.snake

insert image description here
There is no need to explain too much about the game of Snake, you can use the keyboard ⬆️⬇️⬅️➡️ to control it

pac man

If you haven’t played Pac-Man, you should have heard of it. Use the following code to start a game similar to Pac-Man

python -m freegames.pacman

insert image description here

Flappy

The game Flappy is very similar to the very popular Flappy bird before,
insert image description here
you only need to change the game name to start it

python -m freegames.flappy

insert image description here
This time, you need to keep clicking the mouse to control the flight of the green dot. The actual test is a little more difficult than flappy bird

Memory

Memory is translated as memory. The game provides some grids. Clicking on each small grid will display the number hidden behind it, but it will disappear quickly. When you successfully select two identical numbers, it will be displayed as a puzzle, which can be played sex is still high

python -m freegames.memory

insert image description here

maze

This game should not need to be introduced, just find out the corresponding path out of the maze

python -m freegames.maze

insert image description here

Tic Tac Toe

I bet you have played this game, click the screen to place an X or O, when three of the same pattern are in a straight line, you win

python3 -m freegames.tictactoe

insert image description here

view source code

There are more games here so I won’t introduce them one by one. We are no strangers to Turtle, so when we play games, we should think about how developers implement them. Use the following code to generate the source code of the corresponding game in the current directory

python3 -m freegames copy snake

After execution, there will be a snake.py on the desktop, open it to view the corresponding logic of the game
insert image description here
Now we can learn the source code and modify it to achieve more functions and gameplay, hurry up and try it out!

About Python Technical Reserve

It is good to learn Python whether it is employment or sideline business to make money, but to learn Python, you still need a study plan. Finally, everyone will share a full set of Python learning materials to help those who want to learn Python!

1. Learning routes in all directions of Python

The technical points in all directions of Python are sorted out to form a summary of knowledge points in various fields. Its usefulness lies in that you can find corresponding learning resources according to the above knowledge points to ensure that you can learn more comprehensively.
insert image description here

2. Essential development tools for Python

insert image description here

4. Python video collection

Watching the zero-based learning video is the fastest and most effective way to learn. Following the teacher's ideas in the video, it is still very easy to get started from the basics to the in-depth.
insert image description here

5. Practical cases

Optical theory is useless, you have to learn to follow along, and you have to do it yourself, so that you can apply what you have learned to practice. At this time, you can learn from some actual combat cases.insert image description here

6. Python exercises

Check the learning results.
insert image description here

7. Interview information

We must learn Python to find high-paying jobs. The following interview questions are the latest interview materials from first-line Internet companies such as Ali, Tencent, and Byte, and Ali bosses have given authoritative answers. After finishing this set The interview materials believe that everyone can find a satisfactory job.
insert image description here
insert image description here
This full version of the full set of learning materials for Python has been uploaded to CSDN. If you need it, you can scan the QR code of CSDN official certification below on WeChat to get it for free [100% free guarantee]

Guess you like

Origin blog.csdn.net/mynote/article/details/132331817