Advertisement
teddybearg

maze dark

Jun 23rd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.74 KB | None | 0 0
  1. import turtle
  2. import pdb
  3. import random
  4. import time
  5. def wave():
  6. turtle.tracer(0)
  7. turtle.register_shape("bye1.gif")
  8. turtle.register_shape("bye2.gif")
  9. wave=turtle.Turtle()
  10. wave.penup()
  11. wave.setposition(0,-200)
  12. while True:
  13. turtle.tracer(1)
  14. wave.shape("bye1.gif")
  15. time.sleep(0.5)
  16. wave.shape("bye2.gif")
  17. time.sleep(0.5)
  18.  
  19.  
  20. def set(z,q):
  21. turtle.clearscreen()
  22. global wn
  23. global pics
  24. global he; global bo; global le; global bt; global h1; global h2; global sw
  25. global helmbonus; global platebonus; global legsbonus; global bootsbonus; global gauntletsbonus; global swordbonus
  26. global items1; global itmes2; global items3; global items4; global allitems; global itemslist;
  27. global health; global l; global h; global inventory; global direction; global imagelist
  28.  
  29. wn = turtle.Screen()
  30. wn.bgcolor("black")
  31. wn.title("Maze RPG")
  32. wn.setup(1000, 1000)
  33. wn.tracer(0)
  34. turtle.tracer(0)
  35. pics=["closed_chest.gif","opened_chest.gif","cloud.gif","take.gif","front.gif","left.gif","back.gif","right.gif","walls.gif",
  36. "left attack.gif","right attack.gif","front attack.gif","back attack.gif",
  37. "nhead.gif","nbody.gif","nlegs.gif","nboots.gif","nhand1.gif","nhand2.gif","nsword.gif",
  38. "monster1.gif","monster2.gif","monster3.gif","monster4.gif",
  39. "boss1.gif", "boss2.gif","boss3.gif","boss4.gif",
  40. "ghead.gif", "uhead.gif", "vhead.gif","shead.gif",
  41. "ghelm.gif", "uhelm.gif", "vhelm.gif","shelm.gif",
  42. "gbody.gif", "ubody.gif", "vbody.gif","sbody.gif",
  43. "gplate.gif", "uplate.gif","vplate.gif","splate.gif",
  44. "glegs.gif","ulegs.gif","vlegs.gif","slegs.gif",
  45. "gleg.gif", "uleg.gif","vleg.gif","sleg.gif",
  46. "gboots.gif","sboots.gif","vboots.gif","uboots.gif",
  47. "gboot.gif","sboot.gif","vboot.gif","uboot.gif",
  48. "ghand1.gif", "ghand2.gif","shand1.gif","shand2.gif","vhand1.gif","vhand2.gif","uhand1.gif","uhand2.gif",
  49. "ggauntlets.gif","sgauntlets.gif","vgauntlets.gif","ugauntlets.gif",
  50. "gsword.gif","usword.gif","vsword.gif","ssword.gif",
  51. "gswords.gif","uswords.gif","vswords.gif","sswords.gif"]
  52.  
  53. #portrait
  54. he="nhead.gif"
  55. bo="nbody.gif"
  56. le="nlegs.gif"
  57. bt="nboots.gif"
  58. h1="nhand1.gif"
  59. h2="nhand2.gif"
  60. sw="nsword.gif"
  61.  
  62. #bonuses
  63. helmbonus= 0
  64. platebonus = 0
  65. legsbonus = 0
  66. bootsbonus = 0
  67. gauntletsbonus = 0
  68. swordbonus = 0
  69.  
  70. #items
  71. items1=["Steel Helm","Steel Sword","Steel Plate","Steel Legs","Steel Boots","Steel Gauntlets",
  72. "nothing","nothing","nothing","nothing"]
  73. items2=["Gold Helm","Gold Sword","Gold Plate","Gold Legs","Gold Boots","Gold Gauntlets",
  74. "nothing","nothing","nothing","nothing"]
  75. items3=["Vibranium Helm","Vibranium Sword","Vibranium Plate","Vibranium Legs","Vibranium Boots","Vibranium Gauntlets",
  76. "nothing","nothing","nothing","nothing"]
  77. items4=["Unobtainium Helm","Unobtainium Sword","Unobtainium Plate",
  78. "Unobtainium Legs","Unobtainium Boots","Unobtainium Gauntlets",
  79. "nothing","nothing","nothing","nothing"]
  80. allitems=["",items1,items2,items3,items4]
  81. itemslist=["Steel Helm","Steel Sword","Steel Plate","Steel Legs","Steel Boots","Steel Gauntlets",
  82. "Gold Helm","Gold Sword","Gold Plate","Gold Legs","Gold Boots","Gold Gauntlets",
  83. "Vibranium Helm","Vibranium Sword","Vibranium Plate","Vibranium Legs","Vibranium Boots","Vibranium Gauntlets",
  84. "Unobtainium Helm", "Unobtainium Sword", "Unobtainium Plate",
  85. "Unobtainium Legs", "Unobtainium Boots", "Unobtainium Gauntlets"
  86. ]
  87. imagelist=["shelm.gif", "sswords.gif", "splate.gif", "sleg.gif", "sboot.gif", "sgauntlets.gif",
  88. "ghelm.gif", "gswords.gif", "gplate.gif", "gleg.gif", "gboot.gif", "ggauntlets.gif",
  89. "vhelm.gif", "vswords.gif", "vplate.gif", "vleg.gif", "vboot.gif", "vgauntlets.gif",
  90. "uhelm.gif", "uswords.gif", "uplate.gif", "uleg.gif", "uboot.gif", "ugauntlets.gif"]
  91.  
  92. l=1
  93. h=0
  94. health=100
  95. inventory = []
  96. direction="up"
  97. welcome=turtle.Turtle()
  98. welcome.hideturtle()
  99. welcome.color("white")
  100. welcome.penup()
  101. welcome.setposition(0,250)
  102. welcome.write("Welcome to the Dungeon!",False, align="center", font=("Arial", 50, "normal"))
  103. welcome.setposition(0,150)
  104. welcome.write("press arrows keys to move and A to attack", False, align="center", font=("Arial", 14, "normal"))
  105. welcome.setposition(0,130)
  106. welcome.write("click anywhere to start", False, align="center", font=("Arial", 14, "normal"))
  107. welcome.setposition(0, 70)
  108. welcome.write("Enjoy your stay!", False, align="center", font=("Arial", 30, "normal"))
  109. turtle.onscreenclick(start)
  110. while True:
  111. wn.update()
  112.  
  113. def start(o,O):
  114. turtle.clearscreen()
  115. global wn
  116. global pics
  117. global he;
  118. global bo;
  119. global le;
  120. global bt;
  121. global h1;
  122. global h2;
  123. global sw
  124. global helmbonus;
  125. global platebonus;
  126. global legsbonus;
  127. global bootsbonus;
  128. global gauntletsbonus;
  129. global swordbonus
  130. global items1;
  131. global itmes2;
  132. global items3;
  133. global items4;
  134. global allitems;
  135. global itemslist;
  136. global health;
  137. global l;
  138. global h;
  139. global inventory;
  140. global direction
  141. wn.bgcolor("black")
  142. wn.tracer(0)
  143. for image in pics:
  144. turtle.register_shape(image)
  145. class Pen(turtle.Turtle):
  146. def __init__(self):
  147. turtle.Turtle.__init__(self)
  148. self.shape("circle")
  149. self.turtlesize(3)
  150. self.penup()
  151. self.speed(0)
  152.  
  153. class Text(turtle.Turtle):
  154. def __init__(self):
  155. turtle.Turtle.__init__(self)
  156. self.color("white")
  157. self.penup()
  158. self.hideturtle()
  159.  
  160. class Monster(turtle.Turtle):
  161. def __init__(self, x, y):
  162. turtle.Turtle.__init__(self)
  163. self.penup()
  164. self.setposition(x, y)
  165.  
  166. if l == 1:
  167. self.shape("monster1.gif")
  168. self.penup()
  169. self.hp = 50
  170. self.attack = 10
  171. elif l == 2:
  172. self.shape("monster2.gif")
  173. self.penup()
  174. self.hp = 100
  175. self.attack = 20
  176. elif l == 3:
  177. self.shape("monster3.gif")
  178. self.penup()
  179. self.hp = 150
  180. self.attack = 30
  181. elif l == 4:
  182. self.shape("monster4.gif")
  183. self.penup()
  184. self.hp = 200
  185. self.attack = 35
  186.  
  187. class Boss(turtle.Turtle):
  188. def __init__(self, x, y):
  189. turtle.Turtle.__init__(self)
  190. self.penup()
  191. self.setposition(x, y)
  192.  
  193. if l == 1:
  194. self.shape("boss1.gif")
  195. self.penup()
  196. self.hp = 100
  197. self.attack = 20
  198. elif l == 2:
  199. self.shape("boss2.gif")
  200. self.penup()
  201. self.hp = 150
  202. self.attack = 30
  203. elif l == 3:
  204. self.shape("boss3.gif")
  205. self.penup()
  206. self.hp = 200
  207. self.attack = 35
  208. elif l == 4:
  209. self.shape("boss4.gif")
  210. self.penup()
  211. self.hp = 250
  212. self.attack = 40
  213.  
  214. class Player(turtle.Turtle):
  215. def __init__(self):
  216. global health
  217. turtle.Turtle.__init__(self)
  218. self.shape("front.gif")
  219. self.penup()
  220. self.speed(0)
  221. self.Abonus = 10 + swordbonus
  222. self.Dbonus = helmbonus + platebonus + legsbonus + bootsbonus + gauntletsbonus
  223.  
  224. self.hp = health
  225.  
  226. def go_up(self):
  227. global h
  228. self.shape("back.gif")
  229. if (self.xcor(), self.ycor() + 21) in monsterl or (self.xcor(), self.ycor() + 21) in bossl:
  230. self.hp -= 1
  231. self.isalive()
  232. if (self.xcor(), self.ycor() - 21) in walls:
  233. self.goto((self.xcor(), self.ycor()))
  234. else:
  235. self.goto((self.xcor(), self.ycor() - 21))
  236. elif (self.xcor(), self.ycor() + 21) not in walls and (self.xcor(), self.ycor() + 21) not in chestl and (self.xcor(), self.ycor() + 21) not in bossl:
  237. self.goto(self.xcor(), self.ycor() + 21)
  238. elif (self.xcor(), self.ycor() + 21) in chestl:
  239. checking(self.xcor(), self.ycor() + 21)
  240. global direction
  241. direction = "up"
  242. reveal()
  243. h=0
  244. def go_down(self):
  245. self.shape("front.gif")
  246. if (self.xcor(), self.ycor() - 21) in monsterl:
  247. self.hp -= 1
  248. self.isalive()
  249. if (self.xcor(), self.ycor() + 21)in walls:
  250. self.goto((self.xcor(), self.ycor()))
  251. else:
  252. self.goto((self.xcor(), self.ycor() + 21))
  253. elif (self.xcor(), self.ycor() - 21) not in walls and (self.xcor(), self.ycor() - 21) not in chestl:
  254. self.goto(self.xcor(), self.ycor() - 21)
  255. elif (self.xcor(), self.ycor() - 21) in chestl:
  256. checking(self.xcor(), self.ycor() - 21)
  257. global direction
  258. direction = "down"
  259. reveal()
  260.  
  261. def go_left(self):
  262. global h
  263. self.shape("left.gif")
  264. if (self.xcor() - 21, self.ycor()) in monsterl:
  265. self.hp -= 1
  266. self.isalive()
  267. if (self.xcor() + 21, self.ycor()) in walls:
  268. self.goto((self.xcor(), self.ycor()))
  269. else:
  270. self.goto((self.xcor() + 21, self.ycor()))
  271. elif (self.xcor() - 21, self.ycor()) not in walls and (self.xcor() - 21, self.ycor()) not in chestl:
  272. self.goto(self.xcor() - 21, self.ycor())
  273. elif (self.xcor() - 21, self.ycor()) in chestl:
  274. checking(self.xcor() - 21, self.ycor())
  275. global direction
  276. direction = "left"
  277. reveal()
  278. h = 0
  279. def go_right(self):
  280. self.shape("right.gif")
  281. if (self.xcor() + 21, self.ycor()) in monsterl:
  282. self.hp -= 1
  283. self.isalive()
  284. if (self.xcor() - 21, self.ycor()) in walls:
  285. self.goto((self.xcor(), self.ycor()))
  286. else:
  287. self.goto((self.xcor() - 21, self.ycor()))
  288. elif (self.xcor() + 21, self.ycor()) not in walls and (self.xcor() + 21, self.ycor()) not in chestl:
  289. self.goto(self.xcor() + 21, self.ycor())
  290. elif (self.xcor() + 21, self.ycor()) in chestl:
  291. checking(self.xcor() + 21, self.ycor())
  292. global direction
  293. direction = "right"
  294. reveal()
  295.  
  296. def isalive(self):
  297. global health
  298. hptext.undo()
  299. hp = "HP: " + str(player.hp)
  300. hptext.setposition(-420, -390)
  301. hptext.write(hp, False, align="left", font=("Arial", 14, "normal"))
  302. health = player.hp
  303. if self.hp < 1:
  304. turtle.clearscreen()
  305. wn.bgcolor("Black")
  306. died=turtle.Turtle()
  307. died.hideturtle()
  308. died.color("red")
  309. died.penup()
  310. died.write("You Died", False, align="center", font=("Times", 100, "normal"))
  311. died.setposition(0,-100)
  312. died.color("white")
  313. died.write("Click anywhere to try again", False, align="center", font=("Times", 10, "normal"))
  314. turtle.onscreenclick(set)
  315.  
  316. class Chest(turtle.Turtle):
  317. def __init__(self, x, y):
  318. turtle.Turtle.__init__(self)
  319. self.shape("closed_chest.gif")
  320. self.penup()
  321. self.speed(0)
  322. self.goto(x, y)
  323.  
  324. def open(self,x,y):
  325. self.shape("opened_chest.gif")
  326. if not allitems[l]:
  327. chesttext.setposition(x, y+8)
  328. chesttext.write("This chest is empty!", False, align="center", font=("Arial", 10, "normal"))
  329. turtle.ontimer(un, 1000)
  330. else:
  331. item = random.choice(allitems[l])
  332. if item == "nothing":
  333. allitems[l].remove(item)
  334. chesttext.setposition(x,y+8)
  335. chesttext.write("This chest is empty!", False, align="center", font=("Arial", 10, "normal"))
  336. turtle.ontimer(un,1000)
  337.  
  338. elif item not in inventory:
  339. inventory.append(item)
  340. chesttext.setposition(x,y+8)
  341. chesttext.write(item+"!", False, align="center", font=("Arial", 10, "normal"))
  342. allitems[l].remove(item)
  343. display()
  344. turtle.ontimer(un,1000)
  345. #instance of classes
  346. pen=Pen()
  347. player=Player()
  348. damagetext = Text()
  349. hptext = Text()
  350. atext = Text()
  351. dtext = Text()
  352. healtext= Text()
  353. chesttext= Text()
  354. gh = Pen()
  355. gs = Pen()
  356. gp = Pen()
  357. gl = Pen()
  358. gb = Pen()
  359. gg = Pen()
  360. sh = Pen()
  361. ss = Pen()
  362. sp = Pen()
  363. sl = Pen()
  364. sb = Pen()
  365. sg = Pen()
  366. vh = Pen()
  367. vs = Pen()
  368. vp = Pen()
  369. vl = Pen()
  370. vb = Pen()
  371. vg = Pen()
  372. uh = Pen()
  373. us = Pen()
  374. up = Pen()
  375. ul = Pen()
  376. ub = Pen()
  377. ug = Pen()
  378. head = turtle.Turtle()
  379. body = turtle.Turtle()
  380. legs = turtle.Turtle()
  381. boots = turtle.Turtle()
  382. hand1 = turtle.Turtle()
  383. hand2 = turtle.Turtle()
  384. sword = turtle.Turtle()
  385. off = turtle.Turtle()
  386. pool = turtle.Turtle()
  387. pool.penup()
  388. head.penup()
  389. body.penup()
  390. legs.penup()
  391. boots.penup()
  392. hand1.penup()
  393. hand2.penup()
  394. sword.penup()
  395. off.penup()
  396. # drawing interface
  397. head.setposition(-300, -100)
  398. body.setposition(-296, -191)
  399. legs.setposition(-310, -261)
  400. boots.setposition(-316, -303)
  401. hand1.setposition(-400, -251)
  402. hand2.setposition(-159, -205)
  403. sword.setposition(-159,-270)
  404. sh.setposition(-50, -80)
  405. ss.setposition(50, -80)
  406. sp.setposition(150, -80)
  407. sl.setposition(250, -80)
  408. sb.setposition(350, -80)
  409. sg.setposition(450, -80)
  410. gh.setposition(-50, -180)
  411. gs.setposition(50, -180)
  412. gp.setposition(150, -180)
  413. gl.setposition(250, -180)
  414. gb.setposition(350, -180)
  415. gg.setposition(450, -180)
  416. vh.setposition(-50, -280)
  417. vs.setposition(50, -280)
  418. vp.setposition(150, -280)
  419. vl.setposition(250, -280)
  420. vb.setposition(350, -280)
  421. vg.setposition(450, -280)
  422. uh.setposition(-50, -380)
  423. us.setposition(50, -380)
  424. up.setposition(150, -380)
  425. ul.setposition(250, -380)
  426. ub.setposition(350, -380)
  427. ug.setposition(450, -380)
  428. off.setposition(-316,-350)
  429. hptext.setposition(-420, -390)
  430. hptext.write("HP: " + str(player.hp), False, align="left", font=("Arial", 14, "normal"))
  431. atext.setposition(-300,-390)
  432. atext.write("Attack Bonus: "+str(player.Abonus), False, align="left", font=("Arial", 14, "normal"))
  433. dtext.setposition(-300, -420)
  434. dtext.write("Defence Bonus: "+str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  435. head.shape(he)
  436. body.shape(bo)
  437. legs.shape(le)
  438. boots.shape(bt)
  439. hand1.shape(h1)
  440. hand2.shape(h2)
  441. sword.shape(sw)
  442. off.shape("take.gif")
  443.  
  444. #chests and monsters and walls list
  445. chests = []
  446. chestl = []
  447. monsters = []
  448. monsterl = []
  449. been = []
  450. walls = []
  451. bosses=[]
  452. bossl=[]
  453. #maze levels
  454. levels = ["0", "1", "2", "3", "4","5"]
  455. levels[1] = [
  456. "xxxxxxxxxxxxxxxxxxxxxxxbxxxxxxxxxxxxxxxxxxxxxxx",
  457. "xcx x x cx x",
  458. "xmx xxxxxxxxxxxxxxxxxxxxx xxxxxxx x xxx xxx x x",
  459. "x x x m x x m x xcx x x x xc x x",
  460. "x x x x x x x x xmxxxxxxx x x xxxxxxx x x",
  461. "x x xxxxxxxx xxxxxxxx x xx x x x x x x",
  462. "x x x x x x xx x xxxxxx xxxx x",
  463. "x xxxxxxxx xxxx xxxxxxx xx x x x x x",
  464. "x m x x x xxxxxxxxxxxx x x",
  465. "xxxxxxxxxxxxxxxxxxxx xx xxxx x x x x x",
  466. "x x cx x m x xxxxxxxxx x",
  467. "x xxxxxxxxxx x xxxxx xxxxxxxxxxxxxx x x",
  468. "x x x x xc x xxx xxxxx",
  469. "x xxxxxxxx xxxxxxxxxxx x x x xxxxxxxxxx x x",
  470. "xcxc x x x x x xxx x x",
  471. "xxxxxxxx xxxxxxxx xx x x xxxxxxxxx xxxx xcx x x",
  472. "x x x x x x x",
  473. "xxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxx xxx x",
  474. "x x x x x x x",
  475. "x xxxxxxxxxxx x x xxxxxxxxxxxxxxxxxx x xxxx xxx",
  476. "x m x x x x x",
  477. "xxxxxxxxxxx xxx xxxxxxxxxxxxxxxxx xxxxxxxxxxx x",
  478. "xc x",
  479. "xxxxxxxxxxxxxxxxxxxxxxkpxxxxxxxxxxxxxxxxxxxxxxx",
  480. " xxxx ",
  481.  
  482. ]
  483. levels[2] = [
  484. "xxxxxxxxxxxxxxxxxxxxxxxbxxxxxxxxxxxxxxxxxxxxxxx",
  485. "x xc xcx",
  486. "x x xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx x",
  487. "x x x xc x x xcx m x x x",
  488. "x x xxxxxxxxxxxxx x x xx x x xxxxxxxxx x x",
  489. "x x x mx x x xx xxxxxxxx x x",
  490. "x x xxxxxxxxxxxxxxx x x xxxxxxxxx x",
  491. "x x x x xxxxxxxxxxxxx x",
  492. "x xxxxx xxxx xxxxxxxxxx x x x xxxxxxx",
  493. "x x x xxxxxxxxx xxx x mx",
  494. "x xxx xxxxxxxxxxxxxxxxxxx x x x xxxxx",
  495. "x xcx x x m x x xxxxx xxxxxxx x x",
  496. "x x xxxxxxxxxx x x x x x x x x x",
  497. "x x x mxxxxxxxxxxx x x x xxxxx xxxxx x x",
  498. "x x xxxxxxxx x xmx cx x x",
  499. "x x xxxx xxxxxxxxxxxxx xxx xxxxxxxxxxx x",
  500. "x xxxxxxxxcx x x",
  501. "xxxxxxxxxx x x x x xxxxx x xxxxxxxxxxxxxxxxx",
  502. "xcm x x m x x x x x x x",
  503. "xxxx x xxx xxxxxx x x x x x xxxxxxxxxxxxxxxxx x",
  504. "x x x x x x x mcx x",
  505. "x xxxx x xxxxxxxxxx xcx xxxxxxxxxxxxxxxxxxxxx x",
  506. "x x x x x",
  507. "xxxxxxxxxxxxxxxxxxxxxxkpxxxxxxxxxxxxxxxxxxxxxxx",
  508. " xx x ",
  509. ]
  510. levels[3] = [
  511. "xxxxxxxxxxxxxxxxxxxxxxxbxxxxxxxxxxxxxxxxxxxxxxx",
  512. "xc x x x cx xcxmxcx x",
  513. "xxx xxxxx x x x xx xxxxxxx xxxxxx x x x x x x x",
  514. "x xc x x x x x m x x x x x x x x",
  515. "x xxxxx x xx xxxx xxx xx xxxxxx x x xxxxx x",
  516. "x x x x xxxxxmx x x x x x x x x",
  517. "x x x x x xxxxx xxx xxxxxx xxxxxx xxx x x",
  518. "x x xxx x x x x x m x xxx x",
  519. "xxxxx x x xxx xxx xxxxxxxxxxxxxxxxxxx x x",
  520. "xm xxxxxxx x x x x x x x x",
  521. "x x x x xxx xxxxxxxxx x xxxx xxxxxxxx x",
  522. "xxxxxx xxxxxx x x x x x x",
  523. "xc x x x xxxxxxx xxxxxxxxxx x x xxxxxxxx",
  524. "xxxxxxxxx mx x x x x",
  525. "x xxxxx xxxxxxxxxxxxxxxxxxxxxx xxxxxxxx x",
  526. "x xxxxx x x x x x",
  527. "x x x x x x x x xxxxxxxxxxxxxxxxxxxxxxx",
  528. "xxxxx x x xxxxxxxxxxx x cxm x x",
  529. "xc x x x cx x xxx xxxxxxxx x x x x",
  530. "xxx xxxxx xxxxxxxxx x x x x xc xxxxxx xxxx",
  531. "x x x x xmx x x xxx x",
  532. "x xxxxxxxxxxxxxxxxxxx x x x xxx xxxxxxxxxxx x",
  533. "x x x x x",
  534. "xxxxxxxxxxxxxxxxxxxxxxkpxxxxxxxxxxxxxxxxxxxxxxx",
  535. " xx x ",
  536. ]
  537. levels[4] = [
  538. "xxxxxxxxxxxxxxxxxxxxxxxbxxxxxxxxxxxxxxxxxxxxxxx",
  539. "x mx x",
  540. "x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x",
  541. "x x x x x x",
  542. "xxxx xxxx xxxxxxx x xxx xxx x xxxxxxx xxxx xxxx",
  543. "x x x x x x x x x x x x",
  544. "x m xxxx xxxxxxxxx x x xxxxxxxxx xxxx m x",
  545. "xxxxxxxx cx x x xc xxxxxxxx",
  546. "x xxxxxxx xxxx x x xxxx xxxxxxx x",
  547. "x xxxxx x x x x x x x x xxxxx x",
  548. "x xxxxxxxx xxxx x x x x xxxx xxxxxxxx x",
  549. "x xxx cx x xcx xcx x xc xxx x",
  550. "x x xx xxx xxxxx xxxxxx xxxxxx xxxxx xxx xx x x",
  551. "xcx xm x x mx xcx",
  552. "xxx xxxxxxxxxxxxxx xxxx xxxx xxxxxxxxxxxxxx xxx",
  553. "x xm x x mx x",
  554. "xxxxxxxx xxxxxxxxxxxx x x xxxxxxxxxxxx xxxxxxxx",
  555. "x x xm x x x x mx x x",
  556. "x x xxxxx x x xxxxxx xxxxxx x x xxxxx x x",
  557. "x x cxxxxxx x x x x x x xxxxxxc x x",
  558. "x xxxxxxx x x x x x x xxxxxxx x",
  559. "x x x xxxxxxxxxxx x x xxxxxxxxxxx x x x",
  560. "xm x x x x x x mx",
  561. "xxxxxxxxxxxxxxxxxxxxxxkpxxxxxxxxxxxxxxxxxxxxxxx",
  562. " xx x ",
  563. ]
  564.  
  565. #set up the maze
  566. def update_bonus():
  567. player.Abonus = 10 + swordbonus
  568. player.Dbonus = helmbonus + platebonus + legsbonus + bootsbonus + gauntletsbonus
  569.  
  570. def setup_maze(level):
  571. for y in range(len(level)):
  572. for x in range(len(level[y])):
  573. character = level[y][x]
  574. screen_x = -485 + (x * 21)
  575. screen_y = 480 - (y * 21)
  576. if direction=="up":
  577. if character == "p":
  578. player.setposition(screen_x, screen_y)
  579. elif character == "b":
  580. bosses.append(Boss(screen_x, screen_y))
  581. bossl.append((screen_x, screen_y))
  582. elif direction=="down":
  583. if character == "b":
  584. player.setposition(screen_x, screen_y)
  585. if character == "x":
  586. walls.append((screen_x, screen_y))
  587. elif character == "c":
  588. chestl.append((screen_x, screen_y))
  589. elif character == "m":
  590. monsterl.append((screen_x, screen_y))
  591. elif character=="k":
  592. pool.shape("cloud.gif")
  593. pool.setposition(screen_x, screen_y)
  594.  
  595.  
  596.  
  597. def reveal():
  598.  
  599. around=[(player.xcor()-21,player.ycor()+21),(player.xcor(),player.ycor()+21),(player.xcor()+21,player.ycor()+21),
  600. (player.xcor()-21,player.ycor()), (player.xcor()+21,player.ycor()),
  601. (player.xcor()-21,player.ycor()-21),(player.xcor(),player.ycor()-21),(player.xcor()+21,player.ycor()-21)]
  602. if (player.xcor(),player.ycor()) in been:
  603. pass
  604. else:
  605. been.append((player.xcor(),player.ycor()))
  606. for i in around:
  607. if i in walls:
  608. a=walls.index(i)
  609. pen.penup()
  610. pen.goto(walls[a])
  611. pen.shape("walls.gif")
  612. pen.stamp()
  613. elif i in monsterl:
  614. w=monsterl.index(i)
  615. w=str(monsterl[w])
  616. w=w.replace("(",",")
  617. w=w.replace(")",",")
  618. w=w.split(",")
  619. a=int(w[1])
  620. b=int(w[2])
  621. monsters.append(Monster(a,b))
  622.  
  623. elif i in chestl:
  624. v = chestl.index(i)
  625. v = str(chestl[v])
  626. v = v.replace("(", ",")
  627. v = v.replace(")", ",")
  628. v = v.split(",")
  629. c=int(v[1])
  630. d=int(v[2])
  631. chests.append(Chest(c,d))
  632.  
  633.  
  634. def attack():
  635. if direction == "left":
  636. player.shape("left attack.gif")
  637. turtle.ontimer(back, 200)
  638. player.penup()
  639. elif direction == "right":
  640. player.shape("right attack.gif")
  641. turtle.ontimer(back, 200)
  642. player.penup()
  643. elif direction == "up":
  644. player.shape("back attack.gif")
  645. turtle.ontimer(back, 200)
  646. player.penup()
  647. elif direction == "down":
  648. player.shape("front attack.gif")
  649. turtle.ontimer(back, 200)
  650. player.penup()
  651. for monster in monsters:
  652. if direction == "left" and (player.xcor() - 21, player.ycor()) == (monster.xcor(), monster.ycor()):
  653. turtle.tracer(1)
  654. player.goto(player.xcor() - 10, player.ycor())
  655. damagetext.setposition((monster.xcor(), monster.ycor()))
  656. damagetext.write("-" + str(player.Abonus))
  657. monster.hp = monster.hp - player.Abonus
  658. time.sleep(0.2)
  659. player.goto(player.xcor() + 10, player.ycor())
  660. damagetext.undo()
  661. if monster.hp < 1:
  662. turtle.tracer(0)
  663. monsters.remove(monster)
  664. monsterl.remove((monster.xcor(), monster.ycor()))
  665. monster.setposition(1000, 1000)
  666. else:
  667. time.sleep(0.2)
  668. monster.goto(monster.xcor() + 10, monster.ycor())
  669. damagetext.setposition((player.xcor(), player.ycor()))
  670. damagetext.write("-" + str(max(monster.attack - player.Dbonus, 1)))
  671. time.sleep(0.2)
  672. monster.goto(monster.xcor() - 10, monster.ycor())
  673. damagetext.undo()
  674. turtle.tracer(0)
  675. player.hp = player.hp - max(monster.attack - player.Dbonus, 1)
  676. player.isalive()
  677.  
  678. elif direction == "right" and (player.xcor() + 21, player.ycor()) == (monster.xcor(), monster.ycor()):
  679. turtle.tracer(1)
  680. player.goto(player.xcor() + 10, player.ycor())
  681. damagetext.setposition((monster.xcor(), monster.ycor()))
  682. damagetext.write("-" + str(player.Abonus))
  683. monster.hp = monster.hp - player.Abonus
  684. time.sleep(0.2)
  685. player.goto(player.xcor() - 10, player.ycor())
  686. damagetext.undo()
  687. if monster.hp < 1:
  688. turtle.tracer(0)
  689. monsters.remove(monster)
  690. monsterl.remove((monster.xcor(), monster.ycor()))
  691. monster.setposition(1000, 1000)
  692. time.sleep(0.2)
  693. else:
  694. monster.goto(monster.xcor() - 10, monster.ycor())
  695. damagetext.setposition((player.xcor(), player.ycor()))
  696. damagetext.write("-" + str(max(monster.attack - player.Dbonus, 1)))
  697. time.sleep(0.2)
  698. monster.goto(monster.xcor() + 10, monster.ycor())
  699. damagetext.undo()
  700. turtle.tracer(0)
  701. player.hp = player.hp - max(monster.attack - player.Dbonus, 1)
  702. player.isalive()
  703. elif direction == "up" and (player.xcor(), player.ycor() + 21) == (monster.xcor(), monster.ycor()):
  704. turtle.tracer(1)
  705. player.goto(player.xcor(), player.ycor() + 10)
  706. damagetext.setposition((monster.xcor(), monster.ycor()))
  707. damagetext.write("-" + str(player.Abonus))
  708. monster.hp = monster.hp - player.Abonus
  709. time.sleep(0.2)
  710. player.goto(player.xcor(), player.ycor() - 10)
  711. damagetext.undo()
  712. if monster.hp < 1:
  713. turtle.tracer(0)
  714. monsters.remove(monster)
  715. monsterl.remove((monster.xcor(), monster.ycor()))
  716. monster.setposition(1000, 1000)
  717. else:
  718. time.sleep(0.2)
  719. monster.goto(monster.xcor(), monster.ycor() - 10)
  720. damagetext.setposition((player.xcor(), player.ycor()))
  721. damagetext.write("-" + str(max(monster.attack - player.Dbonus, 1)))
  722. time.sleep(0.2)
  723. monster.goto(monster.xcor(), monster.ycor() + 10)
  724. damagetext.undo()
  725. turtle.tracer(0)
  726. player.hp = player.hp - max(monster.attack - player.Dbonus, 1)
  727. player.isalive()
  728. elif direction == "down" and (player.xcor(), player.ycor() - 21) == (monster.xcor(), monster.ycor()):
  729. turtle.tracer(1)
  730. player.goto(player.xcor(), player.ycor() - 10)
  731. damagetext.setposition((monster.xcor(), monster.ycor()))
  732. damagetext.write("-" + str(player.Abonus))
  733. monster.hp = monster.hp - player.Abonus
  734. time.sleep(0.2)
  735. player.goto(player.xcor(), player.ycor() + 10)
  736. damagetext.undo()
  737. if monster.hp < 1:
  738. turtle.tracer(0)
  739. monsters.remove(monster)
  740. monsterl.remove((monster.xcor(), monster.ycor()))
  741. monster.setposition(1000, 1000)
  742. else:
  743. time.sleep(0.2)
  744. monster.goto(monster.xcor(), monster.ycor() + 10)
  745. damagetext.setposition((player.xcor(), player.ycor()))
  746. damagetext.write("-" + str(max(monster.attack - player.Dbonus, 1)))
  747. time.sleep(0.2)
  748. monster.goto(monster.xcor(), monster.ycor() - 10)
  749. damagetext.undo()
  750. turtle.tracer(0)
  751. player.hp = player.hp - max(monster.attack - player.Dbonus, 1)
  752. player.isalive()
  753. for boss in bosses:
  754. if direction == "up" and (player.xcor(), player.ycor() + 21) == (boss.xcor(), boss.ycor()):
  755. turtle.tracer(1)
  756. player.goto(player.xcor(), player.ycor() + 10)
  757. damagetext.setposition((boss.xcor(), boss.ycor()))
  758. damagetext.write("-" + str(player.Abonus))
  759. boss.hp = boss.hp - player.Abonus
  760. time.sleep(0.2)
  761. player.goto(player.xcor(), player.ycor() - 10)
  762. damagetext.undo()
  763. if boss.hp < 1:
  764. turtle.tracer(0)
  765. bosses.remove(boss)
  766. bossl.remove((boss.xcor(), boss.ycor()))
  767. boss.setposition(1000, 1000)
  768. else:
  769. time.sleep(0.2)
  770. boss.goto(boss.xcor(), boss.ycor() - 10)
  771. damagetext.setposition((player.xcor(), player.ycor()))
  772. damagetext.write("-" + str(max(boss.attack - player.Dbonus, 1)))
  773. time.sleep(0.2)
  774. boss.goto(boss.xcor(), boss.ycor() + 10)
  775. damagetext.undo()
  776. turtle.tracer(0)
  777. player.hp = player.hp - max(boss.attack - player.Dbonus, 1)
  778. player.isalive()
  779. def back():
  780. if direction == "left":
  781. player.shape("left.gif")
  782. player.penup()
  783. elif direction == "right":
  784. player.shape("right.gif")
  785. player.penup()
  786. elif direction == "up":
  787. player.shape("back.gif")
  788. player.penup()
  789. elif direction == "down":
  790. player.shape("front.gif")
  791. player.penup()
  792.  
  793. def checking(x,y):
  794. for chest in chests:
  795. if chest.xcor()==x and chest.ycor()==y:
  796. chest.open(x,y)
  797. chests.remove(chest)
  798.  
  799. def display():
  800. def shelm(x, y):
  801. global he
  802. if "Steel Helm" in inventory:
  803. global helmbonus
  804. helmbonus = 1
  805. update_bonus()
  806. head.shape("shead.gif")
  807. he = "shead.gif"
  808. dtext.undo()
  809. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  810.  
  811. def ssword(x, y):
  812. global sw
  813. if "Steel Sword" in inventory:
  814. global swordbonus
  815. swordbonus = 10
  816. update_bonus()
  817. sword.shape("ssword.gif")
  818. sw="ssword.gif"
  819. atext.undo()
  820. atext.write("Attack Bonus: " + str(player.Abonus), False, align="left", font=("Arial", 14, "normal"))
  821.  
  822. def splate(x, y):
  823. global bo
  824. if "Steel Plate" in inventory:
  825. global platebonus
  826. platebonus = 1
  827. update_bonus()
  828. body.shape("sbody.gif")
  829. bo="sbody.gif"
  830. dtext.undo()
  831. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  832.  
  833. def slegs(x, y):
  834. global le
  835. if "Steel Legs" in inventory:
  836. global legsbonus
  837. legsbonus = 1
  838. update_bonus()
  839. legs.shape("slegs.gif")
  840. le="slegs.gif"
  841. dtext.undo()
  842. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  843.  
  844. def sboots(x, y):
  845. global bt
  846. if "Steel Boots" in inventory:
  847. global bootsbonus
  848. bootsbonus = 1
  849. update_bonus()
  850. boots.shape("sboots.gif")
  851. bt="sboots.gif"
  852. dtext.undo()
  853. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  854.  
  855. def sgauntlets(x, y):
  856. global h1
  857. global h2
  858. if "Steel Gauntlets" in inventory:
  859. global gauntletsbonus
  860. gauntletsbonus = 1
  861. update_bonus()
  862. hand1.shape("shand1.gif")
  863. hand2.shape("shand2.gif")
  864. h1="shand1.gif"
  865. h2="shand2.gif"
  866. dtext.undo()
  867. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  868.  
  869. def ghelm(x, y):
  870. global he
  871. if "Gold Helm" in inventory:
  872. global helmbonus
  873. helmbonus = 2
  874. update_bonus()
  875. head.shape("ghead.gif")
  876. he="ghead.gif"
  877. dtext.undo()
  878. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  879.  
  880. def gsword(x, y):
  881. global sw
  882. if "Gold Sword" in inventory:
  883. global swordbonus
  884. swordbonus = 20
  885. update_bonus()
  886. sword.shape("gsword.gif")
  887. sw="gsword.gif"
  888. atext.undo()
  889. atext.write("Attack Bonus: " + str(player.Abonus), False, align="left", font=("Arial", 14, "normal"))
  890.  
  891. def gplate(x, y):
  892. global bo
  893. if "Gold Plate" in inventory:
  894. global platebonus
  895. platebonus = 2
  896. update_bonus()
  897. body.shape("gbody.gif")
  898. bo="gbody.gif"
  899. dtext.undo()
  900. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  901.  
  902. def glegs(x, y):
  903. global le
  904. if "Gold Legs" in inventory:
  905. global legsbonus
  906. legsbonus = 2
  907. update_bonus()
  908. legs.shape("glegs.gif")
  909. le="glegs.gif"
  910. dtext.undo()
  911. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  912.  
  913. def gboots(x, y):
  914. global bt
  915. if "Gold Boots" in inventory:
  916. global bootsbonus
  917. bootsbonus = 2
  918. update_bonus()
  919. boots.shape("gboots.gif")
  920. bt="gboots.gif"
  921. dtext.undo()
  922. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  923.  
  924. def ggauntlets(x, y):
  925. global h1
  926. global h2
  927. if "Gold Gauntlets" in inventory:
  928. global gauntletsbonus
  929. gauntletsbonus = 2
  930. update_bonus()
  931. hand1.shape("ghand1.gif")
  932. hand2.shape("ghand2.gif")
  933. h1="ghand1.gif"
  934. h2="ghand2.gif"
  935. dtext.undo()
  936. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  937.  
  938. def vhelm(x, y):
  939. global he
  940. if "Vibranium Helm" in inventory:
  941. global helmbonus
  942. helmbonus = 3
  943. update_bonus()
  944. head.shape("vhead.gif")
  945. he="vhead.gif"
  946. dtext.undo()
  947. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  948.  
  949. def vsword(x, y):
  950. global sw
  951. if "Vibranium Sword" in inventory:
  952. global swordbonus
  953. swordbonus = 30
  954. update_bonus()
  955. sword.shape("vsword.gif")
  956. sw="vsword.gif"
  957. atext.undo()
  958. atext.write("Attack Bonus: " + str(player.Abonus), False, align="left", font=("Arial", 14, "normal"))
  959.  
  960. def vplate(x, y):
  961. global bo
  962. if "Vibranium Plate" in inventory:
  963. global platebonus
  964. platebonus = 3
  965. update_bonus()
  966. body.shape("vbody.gif")
  967. bo="vbody.gif"
  968. dtext.undo()
  969. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  970.  
  971. def vlegs(x, y):
  972. global le
  973. if "Vibranium Legs" in inventory:
  974. global legsbonus
  975. legsbonus = 3
  976. update_bonus()
  977. legs.shape("vlegs.gif")
  978. le="vlegs.gif"
  979. dtext.undo()
  980. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  981.  
  982. def vboots(x, y):
  983. global bt
  984. if "Vibranium Boots" in inventory:
  985. global bootsbonus
  986. bootsbonus = 3
  987. update_bonus()
  988. boots.shape("vboots.gif")
  989. bt="vboots.gif"
  990. dtext.undo()
  991. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  992.  
  993. def vgauntlets(x, y):
  994. global h1
  995. global h2
  996. if "Vibranium Gauntlets" in inventory:
  997. global gauntletsbonus
  998. gauntletsbonus = 3
  999. update_bonus()
  1000. hand1.shape("vhand1.gif")
  1001. hand2.shape("vhand2.gif")
  1002. h1="vhand1.gif"
  1003. h2="vhand2.gif"
  1004. dtext.undo()
  1005. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  1006.  
  1007. def uhelm(x, y):
  1008. global he
  1009. if "Unobtainium Helm" in inventory:
  1010. global helmbonus
  1011. helmbonus = 4
  1012. update_bonus()
  1013. head.shape("uhead.gif")
  1014. he="uhead.gif"
  1015. dtext.undo()
  1016. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  1017.  
  1018. def usword(x, y):
  1019. global sw
  1020. if "Unobtainium Sword" in inventory:
  1021. global swordbonus
  1022. swordbonus = 40
  1023. update_bonus()
  1024. sword.shape("usword.gif")
  1025. sw="usword.gif"
  1026. atext.undo()
  1027. atext.write("Attack Bonus: " + str(player.Abonus), False, align="left", font=("Arial", 14, "normal"))
  1028.  
  1029. def uplate(x, y):
  1030. global bo
  1031. if "Unobtainium Plate" in inventory:
  1032. global platebonus;
  1033. platebonus = 4;
  1034. update_bonus()
  1035. body.shape("ubody.gif")
  1036. bo="ubody.gif"
  1037. dtext.undo()
  1038. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  1039.  
  1040. def ulegs(x, y):
  1041. global le
  1042. if "Unobtainium Legs" in inventory:
  1043. global legsbonus
  1044. legsbonus = 4
  1045. update_bonus()
  1046. legs.shape("ulegs.gif")
  1047. le="ulegs.gif"
  1048. dtext.undo()
  1049. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  1050.  
  1051. def uboots(x, y):
  1052. global bt
  1053. if "Unobtainium Boots" in inventory:
  1054. global bootsbonus
  1055. bootsbonus = 4
  1056. update_bonus()
  1057. boots.shape("uboots.gif")
  1058. bt="uboots.gif"
  1059. dtext.undo()
  1060. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  1061.  
  1062. def ugauntlets(x, y):
  1063. global h1
  1064. global h2
  1065. if "Unobtainium Gauntlets" in inventory:
  1066. global gauntletsbonus
  1067. gauntletsbonus = 4
  1068. update_bonus()
  1069. hand1.shape("uhand1.gif")
  1070. hand2.shape("uhand2.gif")
  1071. h1="uhand1.gif"
  1072. h2="uhand2.gif"
  1073. dtext.undo()
  1074. dtext.write("Defence Bonus: " + str(player.Dbonus), False, align="left", font=("Arial", 14, "normal"))
  1075.  
  1076. buttonlist = [sh, ss, sp, sl, sb, sg, gh, gs, gp, gl, gb, gg, vh, vs, vp, vl, vb, vg, uh, us, up, ul, ub, ug]
  1077. for i in inventory:
  1078. x = itemslist.index(i)
  1079. buttonlist[x].shape(imagelist[x])
  1080. sh.onclick(shelm)
  1081. ss.onclick(ssword)
  1082. sp.onclick(splate)
  1083. sl.onclick(slegs)
  1084. sb.onclick(sboots)
  1085. sg.onclick(sgauntlets)
  1086. gh.onclick(ghelm)
  1087. gs.onclick(gsword)
  1088. gp.onclick(gplate)
  1089. gl.onclick(glegs)
  1090. gb.onclick(gboots)
  1091. gg.onclick(ggauntlets)
  1092. vh.onclick(vhelm)
  1093. vs.onclick(vsword)
  1094. vp.onclick(vplate)
  1095. vl.onclick(vlegs)
  1096. vb.onclick(vboots)
  1097. vg.onclick(vgauntlets)
  1098. uh.onclick(uhelm)
  1099. us.onclick(usword)
  1100. up.onclick(uplate)
  1101. ul.onclick(ulegs)
  1102. ub.onclick(uboots)
  1103. ug.onclick(ugauntlets)
  1104.  
  1105. def toff(x, y):
  1106. global helmbonus
  1107. global swordbonus
  1108. global platebonus
  1109. global legsbonus
  1110. global bootsbonus
  1111. global gauntletsbonus
  1112. global he
  1113. global bo
  1114. global le
  1115. global bt
  1116. global h1
  1117. global h2
  1118. dtext.undo()
  1119. dtext.write("Defence Bonus: 0", False, align="left", font=("Arial", 14, "normal"))
  1120. atext.undo()
  1121. atext.write("Attack Bonus: 1", False, align="left", font=("Arial", 14, "normal"))
  1122. head.shape("nhead.gif")
  1123. body.shape("nbody.gif")
  1124. legs.shape("nlegs.gif")
  1125. boots.shape("nboots.gif")
  1126. hand1.shape("nhand1.gif")
  1127. hand2.shape("nhand2.gif")
  1128. helmbonus = 0
  1129. platebonus = 0
  1130. legsbonus = 0
  1131. bootsbonus = 0
  1132. gauntletsbonus = 0
  1133. swordbonus = 0
  1134. he = "nhead.gif"
  1135. bo = "nbody.gif"
  1136. le = "nlegs.gif"
  1137. bt = "nboots.gif"
  1138. h1 = "nhand1.gif"
  1139. h2 = "nhand2.gif"
  1140.  
  1141. def un():
  1142. chesttext.undo()
  1143.  
  1144. off.onclick(toff)
  1145.  
  1146. display()
  1147.  
  1148. setup_maze(levels[l])
  1149. reveal()
  1150. turtle.listen()
  1151. turtle.onkeypress(player.go_left, "Left")
  1152. turtle.onkeypress(player.go_right, "Right")
  1153. turtle.onkeypress(player.go_up, "Up")
  1154. turtle.onkeypress(player.go_down, "Down")
  1155. turtle.onkey(attack, "a")
  1156. while True:
  1157. if l ==5:
  1158. if player.xcor() == -2 and player.ycor() == 501 and h==0:
  1159. turtle.clearscreen()
  1160. welcome = turtle.Turtle()
  1161. welcome.hideturtle()
  1162. welcome.penup()
  1163. welcome.setposition(0, 250)
  1164. welcome.write("You did it!", False, align="center", font=("Arial", 100, "normal"))
  1165. welcome.setposition(0, 180)
  1166. welcome.write("You got to the exit!", False, align="center", font=("Arial", 30, "normal"))
  1167. welcome.setposition(0, 130)
  1168. welcome.write("Great job!", False, align="center", font=("Arial", 30, "normal"))
  1169. welcome.setposition(0, 50)
  1170. welcome.write("Thanks for visiting!", False, align="center", font=("Arial", 30, "normal"))
  1171. wave()
  1172. h=1
  1173. break
  1174. if player.xcor() == -2 and player.ycor() == 501:
  1175. l += 1
  1176. start(1,1)
  1177. if player.xcor() == -2 and player.ycor() == -24:
  1178. l -= 1
  1179. start(1,1)
  1180. if player.xcor() == -23 and player.ycor()== -3 and h==0:
  1181. turtle.tracer(1)
  1182. healtext.setposition(-23,5)
  1183. healtext.write("The healing cloud heals all your ailments", False, align="center", font=("Arial", 10, "normal"))
  1184. time.sleep(1)
  1185. healtext.undo()
  1186. player.hp=100
  1187. player.isalive()
  1188. h=1
  1189. turtle.tracer(0)
  1190. wn.update()
  1191.  
  1192.  
  1193. set(1,2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement