Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson1_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
abde1064
authored
Mar 19, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
c6188a1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
diy1.py
diy5.py
diy1.py
0 → 100644
View file @
abde1064
import
turtle
#导入turtle
pen
=
turtle
.
Pen
()
#创建画笔
pen1
=
turtle
.
Pen
()
pen
.
write
(
"春晓
\n
春眠不觉晓,
\n
处处闻啼鸟。
\n
夜来风雨声,
\n
花落知多少。"
,
font
=
(
"Times"
,
20
,
"normal"
))
pen1
.
pensize
(
10
)
pen1
.
pencolor
(
"red"
)
pen1
.
left
(
45
)
pen1
.
forward
(
100
)
pen1
.
circle
(
50
,
180
)
pen1
.
right
(
90
)
pen1
.
circle
(
50
,
180
)
pen1
.
forward
(
100
)
pen1
.
hideturtle
()
pen
.
hideturtle
()
#隐藏画笔
turtle
.
done
()
#保存画布
\ No newline at end of file
diy5.py
0 → 100644
View file @
abde1064
class
Hero
:
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
name
=
name
self
.
hp
=
250
self
.
attack
=
50
def
combat
(
self
,
enemy
):
enemy
.
hp
-=
self
.
attack
info1
=
self
.
name
+
'对'
+
enemy
.
name
+
'发起进攻'
info2
=
'造成'
+
str
(
self
.
attack
)
+
'点伤害,'
if
enemy
.
hp
>
0
:
info3
=
e
nemy
.
name
+
'还剩下'
+
str
(
enemy
.
hp
)
+
'血量'
info
=
in
fo1
+
info2
+
info3
print
(
i
nfo
)
else
:
info3
=
enemy
.
name
+
'阵亡,游戏结束'
info
=
info1
+
info2
+
info3
print
(
info
)
exit
()
class
Player
(
Hero
):
def
__init__
(
self
,
name
):
super
()
.
__init__
(
name
)
self
.
hp
=
200
self
.
attack
=
100
yase
=
Hero
(
"亚瑟"
)
houyi
=
Player
(
"后裔"
,
"射手"
)
houyi
.
combat
(
yase
)
houyi
.
combat
(
yase
)
houyi
.
combat
(
yase
)
\ 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