Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson16_1
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
11c817db
authored
Nov 27, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
1908b6f2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
7 deletions
circles.py
diy1.py
diy2.py
circles.py
0 → 100644
View file @
11c817db
from
turtle
import
*
def
Draw_circle
(
color
,
size
,
x
,
y
):
pencolor
(
color
)
#画笔颜色
pensize
(
8
)
#画笔粗细
pu
()
#抬笔
goto
(
x
,
y
)
pd
()
#落笔
circle
(
size
)
#size表示圆环半径
#黑色
Draw_circle
(
'black'
,
100
,
50
,
0
)
#蓝色
Draw_circle
(
'blue'
,
100
,
-
170
,
0
)
#红色
Draw_circle
(
'red'
,
100
,
270
,
0
)
#绿色
Draw_circle
(
'green'
,
100
,
160
,
-
120
)
#黄色
Draw_circle
(
'yellow'
,
100
,
-
60
,
-
120
)
hideturtle
()
#隐藏画笔
done
()
\ No newline at end of file
diy1.py
View file @
11c817db
import
random
#导入随机模块
class
Hero
(
object
):
class
Hero
(
object
):
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
name
=
name
self
.
name
=
name
...
@@ -7,7 +8,9 @@ class Hero(object):
...
@@ -7,7 +8,9 @@ class Hero(object):
self
.
max_hp
=
self
.
hp
self
.
max_hp
=
self
.
hp
def
cure
(
self
):
# 治疗
def
cure
(
self
):
# 治疗
???
self
.
hp
=
self
.
hp
+
60
if
self
.
hp
>
self
.
max_hp
:
self
.
hp
=
self
.
max_hp
print
(
self
.
name
+
"使用了治疗,血量增加:"
,
60
,
",目前的血量为:"
,
self
.
hp
)
print
(
self
.
name
+
"使用了治疗,血量增加:"
,
60
,
",目前的血量为:"
,
self
.
hp
)
def
combat
(
self
,
enemy
):
# 普通攻击
def
combat
(
self
,
enemy
):
# 普通攻击
...
@@ -33,10 +36,34 @@ class Player(Hero):
...
@@ -33,10 +36,34 @@ class Player(Hero):
self
.
hero_type
=
hero_type
self
.
hero_type
=
hero_type
print
(
"角色"
+
self
.
name
+
"创建成功,英雄类型为:"
,
self
.
hero_type
)
print
(
"角色"
+
self
.
name
+
"创建成功,英雄类型为:"
,
self
.
hero_type
)
print
(
"当前等级、血量、攻击力分别为:"
,
self
.
level
,
self
.
hp
,
self
.
attack
)
print
(
"当前等级、血量、攻击力分别为:"
,
self
.
level
,
self
.
hp
,
self
.
attack
)
def
cure
(
self
):
blood
=
random
.
randint
(
30
,
50
)
self
.
hp
+=
blood
#加血
if
self
.
hp
>
self
.
max_hp
:
self
.
hp
=
self
.
max_hp
print
(
self
.
name
+
"使用了治疗术,血量增加"
,
blood
,
"目前血量为"
,
self
.
hp
)
houyi
=
Player
(
"射手"
,
"后羿"
)
houyi
=
Player
(
"射手"
,
"后羿"
)
yase
=
Hero
(
"垭瑟"
)
yase
=
Hero
(
"垭瑟"
)
houyi
.
combat
(
yase
)
print
(
'-'
*
30
)
yase
.
combat
(
houyi
)
print
(
' 战斗开始'
)
houyi
.
cure
()
while
True
:
yase
.
cure
()
print
(
'-'
*
30
)
\ No newline at end of file
#玩家攻击
choice
=
input
(
"请选择释放的英雄技能:(1攻击 2治疗)q退出"
)
if
choice
==
'q'
:
print
(
'游戏结束'
)
break
elif
choice
==
'1'
:
houyi
.
combat
(
yase
)
#后羿攻击亚瑟
elif
choice
==
'2'
:
houyi
.
cure
()
#使用治疗术
else
:
print
(
'请重新输入1或2或q'
)
continue
#敌方攻击
status
=
random
.
randint
(
1
,
3
)
if
status
==
1
:
yase
.
combat
(
houyi
)
#yase攻击
else
:
yase
.
cure
()
#敌人使用治疗术
diy2.py
0 → 100644
View file @
11c817db
#import turtle #导入模块
from
turtle
import
*
#导入
def
Draw_star
(
length
):
#length表示五角星边长
fillcolor
(
'red'
)
#填充颜色设为红色
begin_fill
()
#开始填充
for
i
in
range
(
5
):
fd
(
length
)
rt
(
144
)
end_fill
()
#结束填充
Draw_star
(
200
)
#调用
bk
(
300
)
Draw_star
(
300
)
done
()
\ 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