Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson6-5-2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2b19f7f5
authored
Jul 14, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
4d8b6805
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
8 deletions
diy.py
diy2.py/diy1.py
diy3.py
diy.py
View file @
2b19f7f5
# 古代测量臂力是靠不同重量的石锁,只能测整数哦。
# 最小的石锁是30公斤最大的石锁是100公斤,注意输入的数字哦。
# 请优化刚刚的代码,并增添交互效果,和自动输出最强三人信息的功能~
import
pygame
from
pygame
import
locals
# 问询处
pygame
.
init
()
screen
=
pygame
.
display
.
set_mode
((
600
,
400
))
FPS
=
pygame
.
time
.
Clock
()
# 归档处
hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'王猛'
,
89
,
'周亮'
,
98
,
'张宇'
,
100
]
for
i
in
range
(
len
(
hero
)):
background
=
pygame
.
image
.
load
(
'bg.png'
)
hero1
=
pygame
.
image
.
load
(
'1.png'
)
hero2
=
pygame
.
image
.
load
(
'2.png'
)
hero3
=
pygame
.
image
.
load
(
'3.png'
)
hero4
=
pygame
.
image
.
load
(
'4.png'
)
hero5
=
pygame
.
image
.
load
(
'5.png'
)
jumpState
=
False
y
=
300
x
=
10
hero
=
[
hero1
,
hero2
,
hero3
,
hero4
,
hero5
]
index
=
0
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
tyep
==
locals
.
QUIT
:
# 打印出臂力最强的三个人和他们对应的臂力值:
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
jumpState
==
False
;
if
event
.
key
==
locals
.
K_SPACE
:
jumpState
=
True
if
jumpState
==
True
:
if
t
>=
-
10
;
a
=
1
if
t
<
0
:
a
=
-
1
y
-=
0.5
*
a
*
(
t
**
2
)
t
-=
1
else
:
jumpState
=
False
t
=
10
wukong
=
hero
[
index
]
index
+=
1
if
index
==
5
:
index
=
0
screen
.
blit
(
background
,(
0
,
0
))
screen
.
blit
(
wukong
,(
200
,
y
)
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
\ No newline at end of file
diy2.py/diy1.py
0 → 100644
View file @
2b19f7f5
import
pygame
import
random
class
Block
(
pygame
.
sprite
.
Sprite
):
def
__init__
(
self
,
image
):
super
()
.
__init__
()
self
.
image
=
image
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
.
x
=
1000
self
.
rect
.
y
=
500
-
self
.
rect
.
heig
stong
=
pygame
.
image
.
load
(
'stone.png'
)
cacti
=
pygame
.
image
.
load
(
'cacti.png'
)
bush
=
pygame
.
image
.
load
(
'bush.png'
)
imp
=
random
.
choice
([
stone
,
cacti
,
bush
])
\ No newline at end of file
diy3.py
0 → 100644
View file @
2b19f7f5
import
pygame
from
pygame
import
locals
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
pygame
.
display
.
set_caption
(
"python"
)
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
exit
()
\ No newline at end of file
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