In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use python to make Mini Game". The editor shows you the operation process through an actual case. The method of operation is simple, fast and practical. I hope this article "how to use python to make Mini Game" can help you solve the problem.
Development tools
Python version: 3.6.4
Related modules:
Pygame module
And some modules that come with Python.
Environment building
Install Python and add it to the environment variable, and pip installs the relevant modules you need.
Introduction of principle
Game introduction:
The image is divided into m × n rectangular blocks, and the rectangular blocks in the lower right corner of the image are replaced with blank blocks, and these rectangular blocks are randomly placed into the shape of the original image. The goal of the game is to restore the randomly placed image to the original image by moving the non-blank block, and it is stipulated that the movement operation only exists when the non-blank block is moved to the blank block.
For example, the following figure shows:
Step by step:
Step1: the initial interface of the game
Since it's a game, there has to be an initial interface, right?
OK, let's first write a game initial interface:
The effect goes like this:
According to the player's own level, you can choose different difficulty jigsaw puzzles.
Step2: define mobile operation
The purpose of defining a mobile operation is to move a jigsaw puzzle (like a nonsense tweet), which is very simple to implement:
Step3: main interface of the game
OK, with the front groundwork, we can begin to implement our main game interface.
First of all, we need to disrupt the puzzle, but random disruption is likely to cause the puzzle to be unsolvable, so we randomly move the puzzle to achieve the effect of disrupting the puzzle, which is the main reason why we define the movement operation of the puzzle first:
Initialize the main interface of the game:
Finally, the functions of display refresh and event response of the main interface are realized.
Step4: game end interface
When the player completes the puzzle, the game end interface needs to be displayed, which is similar to the initial interface of the game, and it is relatively easy to implement:
This is the end of the introduction on "how to make Mini Game with python". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.