Commit 8d6d5075 by BellCodeEditor

save project

parent 2943cddd
apple.png

2.05 KB

bg.png

22.5 KB

body.png

1.4 KB

......@@ -4,7 +4,7 @@ class Hero(object):
def __init__(self, name):
self.name = name
self.level = 1
self.hp = 250
self.hp = 240
self.attack = 40
self.max_hp = self.hp
......@@ -31,22 +31,41 @@ class Hero(object):
class Player(Hero):
def __init__(self,hero_type,name):
super().__init__(name)
self.hp = 200
self.hp = 250
self.attack = 50
self.max_hp = self.hp
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
def cure(self): # 治疗
self.hp+=random.randint(30,50)
if self.hp > self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,目前的血量为:",self.hp)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
houyi.combat(yase)
yase.combat(houyi)
houyi.cure()
yase.cure()
print('-'*50)
print(' 战斗开始')
while True:
print('-'*50)
choice=input('请选择您要使用的技能(1攻击2治疗):')
choice=input('请选择您要使用的技能(1攻击/2治疗/q退出):')
if choice=='q':
print('游戏结束')
break
elif choice=='1':
houyi.combat(yase)
elif choice=='2':
houyi.cure()
else:
print('请重新输入正确选项')
continue
num=random.randint(1,3)
if num == 1:
yase.cure()
else:
yase.combat(houyi)
import pygame
from pygame import locals
pygame.init()
screen = pygame.display.set_mode((660,480))
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
screen.blit(background,(0, 0))
screen.blit(right,(240, 120))
screen.blit(body,(210, 120))
screen.blit(body,(180, 120))
screen.blit(body,(180, 90))
screen.blit(food,(360,300))
pygame.display.update()
\ No newline at end of file
down.png

2.01 KB

left.png

2.07 KB

File added
right.png

2.05 KB

up.png

2.05 KB

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment