当前位置:网站首页>Create a simple game interface using pyGame
Create a simple game interface using pyGame
2022-06-13 01:12:00 【flysh05】
Installation is required first Pygame modular , stay Python Add a reference to the code .
1. The reference code is as follows :
import pygame
2. Define initialization window functions :
def init_Window():
pygame.init()
global WND
WND = pygame.display.set_mode((318, 566))
pygame.display.setcaption(" Test window ")
In the initialization window function , Define window size and window title .
3. Create a loop , Constantly update the interface and detect events
while True:
init_Window()
bg = pygame.image.load("images/bg1.png")
for eventin pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
WND.blit(bg,(0,0))
pygame.display.update()
Load background image , Place the background picture object on the window , Location (0,0) Leftmost corner , The picture has actual dimensions , Set window size , Set to the same size as the picture background , Just the size of the window covered with the design . Update the interface continuously in the cycle , When an exit event is encountered , perform pygame Exit and application exit .
Picture size :

Set the window size according to the size of the graph

The operation effect is as follows :

边栏推荐
- How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic returns of vrsi, bbiboll, WR, bias and RSI indicators
- 刘徽与《九章算术》《海岛算经》简介
- 304. Merge two ordered arrays
- Common skills of quantitative investment - index part 2: detailed explanation of BOL (Bollinger line) index, its code implementation and drawing
- Mysql database password modification
- The tle4253gs is a monolithic integrated low dropout tracking regulator in a small pg-dso-8 package.
- Wikipedia User Guide
- Addition and modification of JPA
- Traditional machine learning classification model predicts the rise and fall of stock prices
- Three threads print digital demo alternately
猜你喜欢
![[Latex] 插入圖片](/img/0b/3304aaa03d3fea3ebb93b0348c3131.png)
[Latex] 插入圖片

Mathematical knowledge arrangement: extremum & maximum, stagnation point, Lagrange multiplier

Et5.0 simply transform referencecollectorieditor

What kind of experience is it to be a software test engineer in a state-owned enterprise: every day is like a war

redis
![[JS] battle chess](/img/1f/83ca6bcb000a5567dc6d3b72463ff8.jpg)
[JS] battle chess

Unity calls alertdialog

Illustrator tutorial, how to add dashes and arrows in illustrator?
![[JS component] browse progress bar](/img/cb/913f446db2cacdb965a3bf619aa478.jpg)
[JS component] browse progress bar

Binary tree -- using hierarchical sequence and middle sequence to determine a tree
随机推荐
[latex] insérer une image
The tle4253gs is a monolithic integrated low dropout tracking regulator in a small pg-dso-8 package.
[003] embedded learning: creating project templates - using stm32cubemx
Canvas game 2048 free map size
Breadth first search for node editor runtime traversal
Stmarl: a spatio temporal multi agentreinforcement learning approach for cooperative traffic
Key point detection data preparation and model design based on u-net Network -- detection model of four key points of industrial components
How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of DBCD, ROC, vroc, Cr and psy index strategy income
Three threads print digital demo alternately
Expression tree - medium order printout
Remove duplicates from an ordered array
Cards are unpredictable
Detailed explanation of Joseph problem
Common skills for quantitative investment - indicators Chapter 3: detailed explanation of RSI indicators, their code implementation and drawing
408 true question - division sequence
Higherhrnet pre training model -- download from network disk
Rotating camera
redis
Several categories of software testing are clear at a glance
Lecture on Compilation Principles