0% found this document useful (0 votes)
72 views5 pages

Aircraft Game

Uploaded by

ss1411354
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views5 pages

Aircraft Game

Uploaded by

ss1411354
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1

The Design of Airplane War Game Based on


Python
Pygame can better meet the diversified needs in the
game development process, and can provide relatively
rich resources for game development and design work,
Abstract: With the development of the times and improve work efficiency, shorten development cycles,
social progress, electronic games have become an and reduce development costs.
important form of people's leisure and entertainment. 2. System Function Analysis
Python language is generally directly embedded in the
game, not only can the performance of the game The game designed in this article is "Airplane War".
engine be significantly improved, but also can fully During the operation of the game, players use the up,
enjoy the outstanding advantages of scripted down, left, and right keys of the keyboard to control our
development. This article focuses on a comprehensive planes that automatically fire bullets at a constant speed
discussion on the design of the airplane war game to attack randomly generated enemy planes.
based on Python, and uses the Python library to Accompanied by background music that fits the battle
develop the game content in depth. state, it is easier to bring players into it. During the game,
some props will be randomly generated [2]. The props
Keywords: python; python library; game design; include life packs, protective covers and nuclear bombs.
airplane The life packs provide the player with the function of
war game adding one life. The protective cover makes our airplane
temporarily invincible until the protective cover
disappears. The nuclear bomb is used to kill the enemy
1. Introduction airplane randomly generated on the full screen in
In the first half of 2021, the actual sales revenue of seconds to help oneself through the dangerous situation
the Chinese game market reached 150.49 billion yuan, [2]. This brings a variety of game functions to players
an increase of 7.8% year-on-year, and the number of and improves player experience. In the game, when our
Chinese game users was nearly 667 million, an plane's life is all used up, the game ends, and then an
increase of 1.38% year-on-year. Among them, the interface for the player to choose to continue the game or
actual sales revenue of China's self-developed games exit will pop up, and after the end, the record module
in the domestic market was 130.112 billion yuan, an will update the game record according to the player's
increase of 8.3% year-on-year, accounting for more score.
than 80% of the actual sales revenue of the Chinese Based on the above analysis, the following factors
game market, and the actual sales revenue in overseas must be considered in the process of development and
markets was US$8.468 billion, an increase of 11.58% design, as shown in Figure 1:
year-on-year [1], China's selfdeveloped games actually
accounted for an upward trend in revenue. Game is a
product that can help people relieve stress, entertain,
and make people feel a sense of accomplishment and
pleasure, and is loved by more and more people. In
recent years, under the promotion of the vigorous
development of Internet technology, the scale of
development of the game industry in China has 3. Overall Game Design
continued to grow, and the output value has reached The programming language Python used in the design
about 250 billion yuan. The corresponding game of this airplane war game is version Python3.7. The
service industry has also achieved rapid development. development tool is IDLE to call the Pygame package
In this era, the game industry has faced tremendous and various functions to develop, run and test the game.
challenges. For a long period of time in the future, The entire process of editing, compiling, and debugging
with the improvement of China's free game research of the game program is based on the PC platform.
and development capabilities, China's game industry Pygame is a Python wrapper module of the SDL
will continue to maintain a highspeed development (Simple DirectMedia Layer) multimedia library. These
trend, and the scale of development will also become
larger and larger, so that games will be accepted and
integrated into a wider audience. In their lives, it has
become one of the important components of people's
leisure and entertainment activities. The advantages of
2

classes and classes enable SDL to support cdrom, audio The main purpose of background music is to render
and video output, keyboard, mouse, and joystick input. the atmosphere and strengthen the overall appeal of the
Pygame is a game library created by using the SDL game. In this "airplane war" game, in terms of
library, which is used to develop Python program background music design, I learned and referenced many
modules for game software. Pygame is a library used by games, quoted different music in different scenes, and
Python. Pygame is a cross-platform Python module that applied different sound effects during the battle. The
focuses on the design of video games, including images, sound effects of a single bullet fired, and the sound
sounds, etc. based on SDL, allowing real-time video effects of double bullets after getting the props and the
game development. Based on this assumption, all main purpose of nuclear bomb sound effects is to fully
required game functions and concepts can be completely demonstrate the intensity of the entire battle process,
simplified into the logic of the game itself, and all thereby promoting the overall progress of the game.
resource structures can be provided by high-level Considering multiple factors and combining actual
languages [3]. needs, a relatively cheerful background music is selected.
IDLE (Integrated Development and Learning Part of the code is as shown in Figure 3:
Environment) has basic IDE (Integrated Development
Environment) functions. It is a very good choice for
noncommercial development. After the Python
installation is completed, IDLE will install it
automatically. The basic functions of IDLE: grammar
emphasis, paragraph indentation, basic text editing, table
key control, debugging program. IDLE is generally a
3.2 Design and Implementation of Enemy Airplane
standard Python release, and IDLE can be executed in an
Module
environment where Python and TK can be executed.
After opening IDLE, the interactive interactive prompt Set the flight status of the enemy airplane to a single
of enhanced interactive command line will be displayed, vertical downward moving flight trajectory, adjust the
and the menu is the "stripping" style of TK. In other flying speed of the enemy airplane according to the
words, click the dotted line of any drop-down menu at difficulty of the game, and call the random function to
the top to upgrade this menu to your own permanent make the enemy airplane appear at different positions at
window. IDLE's tester provides breakpoint, step and the top of the window randomly. When setting the
variable monitoring functions [3]. altitude, to prevent incomplete airplane or a sense of
This article uses many functions in the Python library abruptness when the enemy airplane is spawned, the
to realize the rapid development and design of game width and height of different enemy airplane are passed
content. The main function of the program mainly in during initialization, so that the height of the enemy
implements the definition of member functions and airplane is generated outside the frame, and the width is
member attributes, inherits related functions and adds generated between the width of the frame. Examples of
related game features, such as the realization of the enemy airplane are three types of airplane, large,
incremental function of scores, modules, loop detection medium and small, among which the large and medium
of various functions and monitoring game related events, types of airplane are given HP attributes [4]. The enemy
such as monitoring games the setting of superbullet airplane are divided into three categories: small, mid, and
events and delivery time, etc. and finally run the overall big, and load the width and height data of the enemy
program. Figure 2 below shows the program design airplane model to define the attributes of the enemy
process in detail: airplane's flight speed and number of generations, as
shown in Figure 4. Among them, when the enemy plane
performs collision detection, the blood volume is
reduced by 1. Design enemy airplane generation function
to generate enemy airplane into two sprite groups. One
group of enemies is responsible for collision detection of
all enemy airplane, and the other group is used to
determine the type of enemy airplane's reduction in
blood volume after collision, and pass the draw-line
function Draw bleed bar properties. Among them,
drawing the health bar needs to obtain the position
parameters of the enemy, and by detecting the blood
volume deduction value feedback ratio to achieve the
decreasing visual effect of the health bar.

3.1 Background Music Design and Implementation


3

of the nuclear bomb and shield module for clearing the


screen:

3.5 Game Difficulty Design and Implementation


In terms of difficulty design, this article advocates that
in terms of game difficulty control, the enemy's blood
volume and score can be directly linked, thereby
showing the characteristics of high-risk and high-return
games. In the aspect of enemy planes refreshing, you can
use the form of destroying enemy planes to control the
generation of bosses, ensuring that some game masters
can eliminate enemy planes in a short time, and obtain
3.3 Design and Implementation of the Battle Background
higher scores, and then generate bosses as soon as
In the process of designing background pictures and possible. You can get a higher score by destroying the
background music, we designed six different background boss. According to personal game experience, the game
pictures based on various needs. After the boss is difficulty is divided into six different levels. Figure 8
generated, the background picture will also change. below shows part of the difficulty realization code [5], as
Figure 5 below shows the six different boss-ackground follows:
image:

Figure 8. Part of the difficulty module implementation code

4. Game System Test


The main purpose of system testing is to demonstrate
the stability of the system and the realization of various
functions. In the process of designing and developing
programs, many errors will inevitably occur due to the
influence of various factors. Therefore, system testing is
very important. A software can only be put on the market
after it has been tested [6]. Figure 9 shows the game test
interface, and Table 1 below lists the test content in
detail, as follows:

3.4 Support Prop Design and Implementation


On the basis of learning and borrowing from the
existing airplane war game mode, this article designed a
relatively special bullet form, namely double bullets,
clear screen nuclear bombs, and also added a shield
module and a missile module, in which the airplane
added After shielding, the immune effect can be obtained
in a short time. Figure 6 and Figure 7 are the key codes
4 Table 1. Game test

1 and will be invincible


for a short time;
Example otherwise, if there is no
Airplane war game test
name health value, the game
Example 5. will end immediately
001 Designer: Xiangyu Chen
numble After closing,
Whether the game can achieve the expected open
Test target 9 Record update
function maintest.exe
Operation again
Step Desired result
description
The game interface is
displayed, the background
image is displayed, the
Open the main- background music is
1 Summary
test.exe sounded, and our airplane
and enemy airplane The Python-based airplane war game designed in this paper
appear on the screen,
has completed the basic modules of the game, including
producing bullets.
initialization module, combat interface module, score module
Click the arrow
2 My plane is moving and boss module. The difficulty of the game is upgraded
keys
according to the player’s game progress, while the equipment
My
supply is expanded and the sub-flexibility is improved. As
elimination Can produce props and
3
score reaches a boss spaceship.
well as the life reward mechanism, a airplane war game with
certain number higher playability and more functions has been realized.
After eating the Realize the corresponding References
4
props function
[1] Sina Technology. China Game Industry Report for January-June
Props are generated, and 2021. Available online:
After destroying
5 the background image is https://baijiahao.baidu.com/s?id=1706598133947870355&
the boss
automatically changed wfr=spider&for=pc (accessed on 3 December 2021).
After reaching a [2] Crawford, C. The art of computer game design;
Generate a boss
certain score, Osborne/McGraw-Hill: Berkeley, Calif, UK, 1984.
6 spacecraft that can emit
destroy the [3] Kelly, S. Basic Introduction to PyGame; Springer: New York,
lasers
second boss USA, 2016.
Can eliminate all enemy [4] Adams, E.; Dormans, J. Game mechanics: advanced game
7 Press space design; People's Posts and Telecommunications Publishing
airplane except boss
After our plane is hit, if House: Beijing, China, 2012.
Encountered [5] Sweigart, A. Making Games with Python & Pygame. People's
there is still life, the
8 enemy bullets or Posts and Telecommunications Publishing House: Beijing,
health value will be
enemy airplane China, 2012.
automatically reduced by
[6] Kelly, S. Python, PyGame, and Raspberry Pi Game
Development; Springer: New York, USA, 2019.

You might also like