Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
13680905
Break the Stones3
Commits
60931e6c
Commit
60931e6c
authored
Oct 30, 2020
by
13680905
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
a30ce040
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
text.py
text.py
+58
-0
No files found.
text.py
0 → 100644
View file @
60931e6c
'''from PyQt5.QtGui import *
import os
img = QImage()
path = "./images"
for root, dirs, files in os.walk(path):
for name in files:
print(name)
if name.endswith(".png"):
print(name)
print("./img/" + name)
img.load("./img/" + name)
img.save("./img/" + name)'''
import
pygame
from
planes_sprites
import
*
pygame
.
init
()
#创建游戏窗口大小
screen
=
pygame
.
display
.
set_mode
((
480
,
700
))
#创建背景图像
bg
=
pygame
.
image
.
load
(
"./images/background.png"
)
screen
.
blit
(
bg
,(
0
,
0
))
pygame
.
display
.
update
()
#创建英雄飞机
hero
=
pygame
.
image
.
load
(
"./images/me1.png"
)
screen
.
blit
(
hero
,(
150
,
500
))
#在所有绘制工作完成后,统一调用update方法
pygame
.
display
.
update
()
#创建时钟对象
clock
=
pygame
.
time
.
Clock
()
hero_rect
=
pygame
.
Rect
(
150
,
500
,
102
,
126
)
i
=
0
l
=
0
#建立精灵组和精灵
enemy
=
GameSprite
(
"./images/enemy1.png"
)
enemy2
=
GameSprite
(
"./images/enemy2.png"
,
2
)
enemy_group
=
pygame
.
sprite
.
Group
(
enemy
,
enemy2
)
#创建游戏内循环
while
True
:
if
hero_rect
.
y
<
-
102
:
hero_rect
=
pygame
.
Rect
(
150
,
700
,
102
,
126
)
clock
.
tick
(
60
)
hero_rect
.
y
-=
1
screen
.
blit
(
bg
,
(
0
,
0
))
screen
.
blit
(
hero
,
hero_rect
)
for
event
in
pygame
.
event
.
get
():
print
(
event
)
if
event
.
type
==
pygame
.
QUIT
:
print
(
"游戏退出"
)
if
event
.
type
==
pygame
.
KEYDOWN
:
if
event
.
key
==
276
:
print
(
"测试为左"
)
print
(
"键位测试"
)
enemy_group
.
update
()
enemy_group
.
draw
(
screen
)
pygame
.
display
.
update
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment