#
monsters = []
def generate_monster(monster_quantity):
for _ in range(monster_quantity):
monster = tt.Turtle()
monster.penup()
monster.hideturtle()
monster.speed(random.randint(1,4))
monster.shape(r'C:\Users\workd\OneDrive\Máy tính\HP2\SP\imgs\monster.gif')
monster.goto(random.randint(-480,480), random.randint(-240,240))
monster.showturtle()
monsters.append(monster)
move_monster()
def move_monster():
time.sleep(3)
while True:
for monster in monsters:
monster.goto(random.randint(-480,480), random.randint(-240,240))
def is_touch_monster():
for monster in monsters:
if monster.distance(tt_player) < 20:
sound_lose.play()
tt_text.goto(0,0)
bg.clear()
tt_text.write('You loose', align= 'center', font= ('Arial',40,'bold'))
bg.ontimer(is_touch_monster, 100)
is_touch_monster()
#
bg.onkey(choose_red,'r')
bg.onkey(choose_blue,'b')
bg.onkeypress(up,'Up')
bg.onkeypress(down,'Down')
bg.onkeypress(left,'Left')
bg.onkeypress(right,'Right')
# bg.onkey(beam,'Space')
bg.listen()
tt.done()
Đăng nhập để tham gia bình luận