Guest User

Untitled

a guest
Jun 8th, 2020
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 63.85 KB | None | 0 0
  1.  
  2. import pygame
  3. import math
  4. pygame.init()
  5.  
  6.  
  7. #------------------------------------------------- start screen
  8.  
  9. def startscreen():
  10. window.fill(0,0,0)
  11.  
  12. # ---------- MUSIC SECTION
  13.  
  14. pygame.mixer.init()
  15.  
  16.  
  17. music = pygame.mixer.music.load("backgroundsong.wav")
  18. pygame.mixer.music.play(-1)
  19.  
  20. # shooting sound
  21. shootsound = pygame.mixer.Sound("shootsound.wav")
  22.  
  23. # hit the ice bergs sound
  24. icesound = pygame.mixer.Sound("shoot.wav")
  25.  
  26. # hurt sound
  27. hurtsound = pygame.mixer.Sound("hite.wav")
  28.  
  29. # jumpsound
  30. jumpsound = pygame.mixer.Sound("sjump.wav")
  31.  
  32. #coin sound
  33. coinsound = pygame.mixer.Sound("coinssound.wav")
  34.  
  35. # enemy hit sound
  36. hitesound = pygame.mixer.Sound("h.wav")
  37.  
  38. # enemy death sound
  39. deathsound = pygame.mixer.Sound("death.wav")
  40.  
  41. # health gain
  42. healthsound = pygame.mixer.Sound("pw.wav")
  43.  
  44. # walking sound
  45. icesound = pygame.mixer.Sound("ices.wav")
  46.  
  47. # ---------------------------------
  48.  
  49.  
  50.  
  51.  
  52. # window
  53. window = pygame.display.set_mode((800,800))
  54. pygame.display.set_caption("new World")
  55. #
  56. # error bloccks
  57. erblock = pygame.image.load("error.png")
  58.  
  59. # trees images
  60. treo = pygame.image.load("tree.png")
  61.  
  62. # mountains
  63. mounto = pygame.image.load("mount.png")
  64.  
  65. # platform images
  66. blocks = pygame.image.load("block.png")
  67.  
  68. # coins image
  69. heart = pygame.image.load("heart.png")
  70.  
  71. # heart image
  72. heartingss = pygame.image.load("health.png")
  73.  
  74.  
  75.  
  76. # define the shooting sound for the player ------------------------
  77.  
  78.  
  79.  
  80.  
  81. #---------------------------------------------
  82.  
  83.  
  84. # window
  85. window = pygame.display.set_mode((800,800))
  86. pygame.display.set_caption("new World")
  87. #
  88. # error bloccks
  89. erblock = pygame.image.load("error.png")
  90.  
  91. # trees images
  92. treo = pygame.image.load("tree.png")
  93.  
  94. # mountains
  95. mounto = pygame.image.load("mount.png")
  96.  
  97. # platform images
  98. blocks = pygame.image.load("block.png")
  99.  
  100. # coins image
  101. heart = pygame.image.load("heart.png")
  102.  
  103. # heart image
  104. heartingss = pygame.image.load("health.png")
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112. # background
  113. bg = pygame.image.load("bg.png")
  114.  
  115.  
  116. # ice mountains
  117. ice = pygame.image.load("ice1.png")
  118.  
  119. #
  120. icyy = pygame.image.load("ice2.png")
  121. # player projectiles
  122. slash = pygame.image.load("heart.png")
  123. # space bar key
  124. spi = [
  125. pygame.image.load("j1.png"),
  126. pygame.image.load("j2.png")]
  127.  
  128. standingright = [pygame.image.load("d1.png"),
  129. pygame.image.load("d2.png"),
  130. pygame.image.load("d3.png"),
  131. pygame.image.load("d4.png"),
  132. pygame.image.load("d5.png"),
  133. pygame.image.load("d6.png"),
  134. pygame.image.load("d7.png"),
  135. pygame.image.load("d8.png"),
  136. pygame.image.load("d9.png"),
  137. pygame.image.load("d10.png"),
  138. pygame.image.load("d11.png"),
  139. pygame.image.load("d12.png"),
  140. pygame.image.load("d13.png"),
  141. pygame.image.load("d14.png"),
  142. pygame.image.load("d15.png")]
  143.  
  144. standingleft =[pygame.image.load("s1.png"),
  145. pygame.image.load("s2.png"),
  146. pygame.image.load("s3.png"),
  147. pygame.image.load("s4.png"),
  148. pygame.image.load("s5.png"),
  149. pygame.image.load("s6.png"),
  150. pygame.image.load("s7.png"),
  151. pygame.image.load("s8.png"),
  152. pygame.image.load("s9.png"),
  153. pygame.image.load("s10.png"),
  154. pygame.image.load("s11.png"),
  155. pygame.image.load("s12.png"),
  156. pygame.image.load("s13.png"),
  157. pygame.image.load("s14.png"),
  158. pygame.image.load("s15.png")]
  159.  
  160.  
  161.  
  162. rights = [pygame.image.load("L1.png"),
  163. pygame.image.load("L2.png"),
  164. pygame.image.load("L3.png"),
  165. pygame.image.load("L4.png"),
  166. pygame.image.load("L5.png"),
  167. pygame.image.load("L6.png"),
  168. pygame.image.load("L7.png"),
  169. pygame.image.load("L8.png"),
  170. pygame.image.load("L9.png"),
  171. pygame.image.load("L10.png"),
  172. pygame.image.load("L11.png"),
  173. pygame.image.load("L12.png"),
  174. pygame.image.load("L13.png"),
  175. pygame.image.load("L14.png"),
  176. pygame.image.load("L15.png")]
  177.  
  178.  
  179. lefts = [pygame.image.load("e1.png"),
  180. pygame.image.load("e2.png"),
  181. pygame.image.load("e3.png"),
  182. pygame.image.load("e4.png"),
  183. pygame.image.load("e5.png"),
  184. pygame.image.load("e6.png"),
  185. pygame.image.load("e7.png"),
  186. pygame.image.load("e8.png"),
  187. pygame.image.load("e9.png"),
  188. pygame.image.load("e10.png"),
  189. pygame.image.load("e11.png"),
  190. pygame.image.load("e12.png"),
  191. pygame.image.load("e13.png"),
  192. pygame.image.load("e14.png"),
  193. pygame.image.load("e15.png")]
  194.  
  195. games = [pygame.image.load("key1.png"),
  196. pygame.image.load("key2.png"),
  197. pygame.image.load("key3.png"),
  198. pygame.image.load("key4.png"),
  199. pygame.image.load("key5.png"),
  200. pygame.image.load("key6.png"),
  201. pygame.image.load("key7.png")]
  202.  
  203.  
  204.  
  205.  
  206.  
  207. # trees
  208. tree = pygame.image.load("treo.png")
  209.  
  210. # bushes
  211. bushes = pygame.image.load("bush.png")
  212. #
  213. class tree:
  214. def __init__(self,x,y,height,width,color):
  215. self.x = x
  216. self.y = y
  217. self.height = height
  218. self.width = width
  219. self.errors = pygame.image.load("treo.png")
  220. self.color = color
  221. self.rect = pygame.Rect(x,y,height,width)
  222. def draw(self):
  223. self.rect.topleft = (self.x,self.y)
  224. window.blit(self.errors,self.rect)
  225. black = (0,0,0)
  226. tree1 = tree(150,300,60,60,black)
  227. trees = [tree1]
  228.  
  229.  
  230. class bush:
  231. def __init__(self,x,y,height,width,color):
  232. self.x = x
  233. self.y = y
  234. self.height = height
  235. self.width = width
  236. self.errors = pygame.image.load("bush.png")
  237. self.color = color
  238. self.rect = pygame.Rect(x,y,height,width)
  239. def draw(self):
  240. self.rect.topleft = (self.x,self.y)
  241. window.blit(self.errors,self.rect)
  242. bush1 = bush(-987210,-87510,100,100,black)
  243. bushes = [bush1]
  244.  
  245. # erro block class
  246. class error:
  247. def __init__(self,x,y,height,width,color):
  248. self.x = x
  249. self.y = y
  250. self.height = height
  251. self.width = width
  252. self.erblock = pygame.image.load("error.png")
  253. self.color = color
  254. self.rect = pygame.Rect(x,y,height,width)
  255. def draw(self):
  256. self.rect.topleft = (self.x,self.y)
  257. player_rect = erblock.get_rect(center = self.rect.center)
  258. player_rect.centerx += 20 # 10 is just an example
  259. player_rect.centery += -20 # 15 is just an example
  260. window.blit(self.erblock,self.rect)
  261. white = (255,255,255)
  262. error1 = error(-60,504,50,50,white)
  263. errors = [error1]
  264. platformGroup = pygame.sprite.Group
  265. platformList = []
  266. level = ["p ",
  267. "p ",
  268. "p ",
  269. "p ",
  270. "p ",
  271. "p ",
  272. "p ",
  273. "p ",
  274. "p ",
  275. "p ",
  276. " ",]
  277. for iy, row in enumerate(level):
  278. for ix, col in enumerate(row):
  279. if col == "p":
  280. new_platforms = error(-60, iy*70, 50,60,(255,255,255))
  281. errors.append(new_platforms)
  282.  
  283.  
  284. # my players class
  285. # player class
  286.  
  287. class player:
  288. def __init__(self,x,y,height,width,color):
  289. self.x = x
  290. self.y = y
  291. self.color = color
  292. self.height = height
  293. self.width = width
  294. self.speed = 5
  295. self.isJump = False
  296. self.JumpCount = 10
  297. self.fall = 0
  298. #hit box
  299. self.hitbox = (self.x + 20, self.y, 28, 60)
  300. self.stand = pygame.image.load("stands.png")
  301. self.rights = [pygame.image.load("L1.png"),
  302. pygame.image.load("L2.png"),
  303. pygame.image.load("L3.png"),
  304. pygame.image.load("L4.png"),
  305. pygame.image.load("L5.png"),
  306. pygame.image.load("L6.png"),
  307. pygame.image.load("L7.png"),
  308. pygame.image.load("L8.png"),
  309. pygame.image.load("L9.png"),
  310. pygame.image.load("L10.png"),
  311. pygame.image.load("L11.png"),
  312. pygame.image.load("L12.png"),
  313. pygame.image.load("L13.png"),
  314. pygame.image.load("L14.png"),
  315. pygame.image.load("L15.png")]
  316. self.lefts = [pygame.image.load("e1.png"),
  317. pygame.image.load("e2.png"),
  318. pygame.image.load("e3.png"),
  319. pygame.image.load("e4.png"),
  320. pygame.image.load("e5.png"),
  321. pygame.image.load("e6.png"),
  322. pygame.image.load("e7.png"),
  323. pygame.image.load("e8.png"),
  324. pygame.image.load("e9.png"),
  325. pygame.image.load("e10.png"),
  326. pygame.image.load("e11.png"),
  327. pygame.image.load("e12.png"),
  328. pygame.image.load("e13.png"),
  329. pygame.image.load("e14.png"),
  330. pygame.image.load("e15.png")]
  331. self.standingright = [pygame.image.load("d1.png"),
  332. pygame.image.load("d2.png"),
  333. pygame.image.load("d3.png"),
  334. pygame.image.load("d4.png"),
  335. pygame.image.load("d5.png"),
  336. pygame.image.load("d6.png"),
  337. pygame.image.load("d7.png"),
  338. pygame.image.load("d8.png"),
  339. pygame.image.load("d9.png"),
  340. pygame.image.load("d10.png"),
  341. pygame.image.load("d11.png"),
  342. pygame.image.load("d12.png"),
  343. pygame.image.load("d13.png"),
  344. pygame.image.load("d14.png"),
  345. pygame.image.load("d15.png")]
  346. self.standingleft =[pygame.image.load("s1.png"),
  347. pygame.image.load("s2.png"),
  348. pygame.image.load("s3.png"),
  349. pygame.image.load("s4.png"),
  350. pygame.image.load("s5.png"),
  351. pygame.image.load("s6.png"),
  352. pygame.image.load("s7.png"),
  353. pygame.image.load("s8.png"),
  354. pygame.image.load("s9.png"),
  355. pygame.image.load("s10.png"),
  356. pygame.image.load("s11.png"),
  357. pygame.image.load("s12.png"),
  358. pygame.image.load("s13.png"),
  359. pygame.image.load("s14.png"),
  360. pygame.image.load("s15.png")]
  361. self.rights = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.rights]
  362. self.lefts = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.lefts]
  363. self.standingright = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.standingright]
  364. self.standingleft = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.standingleft]
  365. self.bo_index = 0
  366. self.anim_index = 0
  367. self.stans_index = 0
  368. self.direction = "right"
  369. self.direction = "left"
  370. self.direction = "standright"
  371. self.direction = "standleft"
  372. self.health = 10
  373. self.hitbox = (self.x + -30, self.y + 0, 31, 57)
  374. # playerman hitbox
  375. self.hits = (self.x + 20, self.y, 28,60)
  376.  
  377. self.rect = pygame.rect = pygame.Rect(self.x,self.y,width, height)
  378.  
  379.  
  380.  
  381. def draw(self):
  382. self.rect.topleft = (self.x,self.y)
  383.  
  384. if self.direction == "right":
  385. image_list = self.rights
  386. elif self.direction == "standright":
  387. image_list = self.standingright
  388. elif self.direction == "left":
  389. image_list = self.lefts
  390. else:
  391. image_list = self.standingleft
  392.  
  393. if self.anim_index >= len(image_list):
  394. self.anim_index = 0
  395. player_image = image_list[self.anim_index]
  396. self.anim_index += 1
  397.  
  398. player_rect = player_image.get_rect(center = self.rect.center)
  399. player_rect.centerx += 20 # 10 is just an example
  400. player_rect.centery += -20 # 15 is just an example
  401. window.blit(player_image, player_rect)
  402. self.hits = (self.x + 20, self.y, 28,60)
  403. pygame.draw.rect(window, (255,0,0), (self.hitbox[0], self.hitbox[1] - 60, 80, 10)) # NEW
  404. pygame.draw.rect(window, (0,255,0), (self.hitbox[0], self.hitbox[1] - 60, 80 - (5 * (10 - self.health)), 10))
  405. self.hitbox = (self.x + -30, self.y + 0, 31, 57)
  406.  
  407.  
  408. # health icon
  409. heat = pygame.image.load("health.png")
  410. # player icon
  411. icon = pygame.image.load("icon.png")
  412.  
  413.  
  414. # floor platforms class
  415. class platform:
  416. def __init__(self,x,y,height,width,color):
  417. self.x = x
  418. self.y = y
  419. self.height = height
  420. self.width = width
  421. self.color = color
  422. self.blocks = pygame.image.load("block.png")
  423. self.rect = pygame.Rect(x,y,height,width)
  424. def draw(self):
  425. self.rect.topleft = (self.x,self.y)
  426. window.blit(self.blocks,self.rect)
  427.  
  428.  
  429.  
  430. # trees class
  431. class icess:
  432. def __init__(self,x,y,height,width,color):
  433. self.x = x
  434. self.y = y
  435. self.height = height
  436. self.width = width
  437. self.color = color
  438. self.icyy = pygame.image.load("ice2.png")
  439. self.icyy = pygame.transform.scale(self.icyy,(self.icyy.get_width()-44,self.icyy.get_height()-44))
  440. self.rect = pygame.Rect(x,y,height,width)
  441. self.hitbox = (self.x + 5, self.y + 1, 10, 72)
  442. def draw(self):
  443. self.rect.topleft = (self.x,self.y)
  444. player_rect = icyy.get_rect(center = self.rect.center)
  445. player_rect.centerx += 0 # 10 is just an example
  446. player_rect.centery += -50 # 15 is just an example
  447. window.blit(icyy, player_rect)
  448. self.hitbox = (self.x + 5, self.y + 1, 10, 72)
  449. black = (0,0,0)
  450. ice1 = icess(255450,16540,50434,134320,black)
  451. icing = [ice1]
  452. #
  453.  
  454. class dice:
  455. def __init__(self,x,y,height,width,color):
  456. self.x = x
  457. self.y = y
  458. self.height = height
  459. self.width = width
  460. self.color = color
  461. self.ice = pygame.image.load("ice1.png")
  462. self.ice = pygame.transform.scale(self.ice,(self.ice.get_width()-44,self.ice.get_height()-44))
  463. self.rect = pygame.Rect(x,y,height,width)
  464. # the hitbox our projectiles will be colliding with
  465. self.hitbox = (self.x + 0, self.y + 1, 10, 72)
  466. def draw(self):
  467. self.rect.topleft = (self.x,self.y)
  468. player_rect = ice.get_rect(center = self.rect.center)
  469. player_rect.centerx += -14 # 10 is just an example
  470. player_rect.centery += -15 # 15 is just an example
  471. window.blit(ice, player_rect)
  472. # hit box our projectile will be colliding with
  473. self.hitbox = (self.x + 0, self.y + 1, 10, 72)
  474.  
  475.  
  476. black = (0,0,0)
  477. ice2 = dice(254550,494540,10,30,black)
  478. dicing = [ice2]
  479.  
  480. # keys left right up[ down
  481. class Snow:
  482.  
  483. def __init__(self, x, y, height, width, color):
  484. self.color = color
  485. self.x = x
  486. self.y = y
  487. self.height = height
  488. self.width = width
  489. self.games = [
  490. pygame.image.load("key1.png"),
  491. pygame.image.load("key2.png"),
  492. pygame.image.load("key3.png"),
  493. pygame.image.load("key4.png"),
  494. pygame.image.load("key5.png"),
  495. pygame.image.load("key6.png"),
  496. pygame.image.load("key7.png")
  497. ]
  498. self.anim_index = 0
  499. self.direction = "idk"
  500. self.rect = pygame.Rect(x,y,height,width)
  501. self.delay = 150
  502. self.next_frame = pygame.time.get_ticks() + self.delay
  503.  
  504. def draw(self):
  505. self.rect.topleft = (self.x,self.y)
  506. if self.direction == "idk":
  507. window.blit(self.games[self.anim_index], self.rect)
  508.  
  509. if pygame.time.get_ticks() >= self.next_frame:
  510. self.next_frame = pygame.time.get_ticks() + self.delay
  511.  
  512. self.anim_index += 1
  513. if self.anim_index == len(self.games):
  514. self.anim_index = 0
  515.  
  516. black = (0,0,)
  517. snow1 = Snow(340,550,50,150,black)
  518. snowing = [snow1]
  519.  
  520. # space bar key
  521.  
  522. class spie:
  523. def __init__(self,x,y,height,width,color):
  524.  
  525. self.color = color
  526. self.x = x
  527. self.y = y
  528. self.height = height
  529. self.width = width
  530. self.spi = [
  531. pygame.image.load("j1.png"),
  532. pygame.image.load("j2.png")]
  533. self.anim_index = 0
  534. self.direction = "so"
  535. self.rect = pygame.Rect(x,y,height,width)
  536. self.delay = 150
  537. self.next_frame = pygame.time.get_ticks() + self.delay
  538. def draw(self):
  539. self.rect.topleft = (self.x,self.y)
  540. if self.direction == "so":
  541. window.blit(self.spi[self.anim_index], self.rect)
  542.  
  543. if pygame.time.get_ticks() >= self.next_frame:
  544. self.next_frame = pygame.time.get_ticks() + self.delay
  545.  
  546. self.anim_index += 1
  547. if self.anim_index == len(self.spi):
  548. self.anim_index = 0
  549.  
  550. black = (0,0,)
  551. spie1 = spie(10,640,50,150,black)
  552. spies = [spie1]
  553.  
  554.  
  555. # coins class
  556. class coin:
  557. def __init__(self,x,y,height,width,color):
  558. self.x = x
  559. self.y = y
  560. self.heart = pygame.image.load("heart.png")
  561. self.height = height
  562. self.width = width
  563. self.color = color
  564. self.rect = pygame.Rect(x,y,height,width)
  565. def draw(self):
  566. self.rect.topleft = (self.x,self.y)
  567. player_rect = heart.get_rect(center = self.rect.center)
  568. player_rect.centerx += 0 # 10 is just an example
  569. player_rect.centery += 0 # 15 is just an example
  570. window.blit(heart, player_rect)
  571.  
  572.  
  573. # bullet class
  574.  
  575.  
  576. class projectile(object):
  577. def __init__(self, x, y, dirx, diry, color):
  578. self.x = x
  579. self.y = y
  580. self.dirx = dirx
  581. self.diry = diry
  582. self.slash = pygame.image.load("heart.png")
  583. self.rect = self.slash.get_rect()
  584. self.rect.topleft = ( self.x, self.y )
  585. self.speed = 10
  586. self.color = color
  587. def move(self):
  588. self.x += self.dirx * self.speed
  589. self.y += self.diry * self.speed
  590. def draw(self, window):
  591. self.rect.topleft = (round(self.x), round(self.y))
  592. window.blit(self.slash,self.rect)
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601. sigh = pygame.image.load("alert.png")
  602. class alrt:
  603. def __init__(self,x,y,height,width,color):
  604. self.x = x
  605. self.y = y
  606. self.sigh = pygame.image.load("alert.png")
  607. self.sigh = pygame.transform.scale(self.sigh,(self.sigh.get_width()*3,self.sigh.get_height()*3))
  608. self.height = height
  609. self.width = width
  610. self.color = color
  611. self.rect = pygame.Rect(x,y,height,width)
  612. def draw(self):
  613. self.rect.topleft = (self.x,self.y)
  614. player_rect = sigh.get_rect(center = self.rect.center)
  615. player_rect.centerx += 10 # 10 is just an example
  616. player_rect.centery += -15 # 15 is just an example
  617. window.blit(self.sigh,self.rect)
  618. black = (0,0,0)
  619. alert1 = alrt(170,370,50,50,black)
  620. alerting = [alert1]
  621.  
  622. # exit image
  623. exits = pygame.image.load("exit.png")
  624. class exi:
  625. def __init__(self,x,y,height,width,color):
  626. self.x = x
  627. self.y = y
  628. self.color = color
  629. self.height = height
  630. self.width = width
  631. self.exits = pygame.image.load("exit.png")
  632. self.exits = pygame.transform.scale(self.exits,(self.exits.get_width()*3,self.exits.get_height()*3))
  633. self.rect = pygame.Rect(x,y,height,width)
  634. def draw(self):
  635. self.rect.topleft = (self.x,self.y)
  636. window.blit(self.exits,self.rect)
  637.  
  638. # define the text class
  639. black = (0,0,0)
  640. exit1 = exi(160,140,40,40,black)
  641. exiting = [exit1]
  642.  
  643.  
  644. # text imgae
  645. te = pygame.image.load("text.png")
  646. # text class
  647. class texto:
  648. def __init__(self,x,y,height,width,color):
  649. self.x = x
  650. self.y = y
  651. self.height = height
  652. self.width = width
  653. self.color = color
  654. self.te = pygame.image.load("text.png")
  655. self.te = pygame.transform.scale(self.te,(self.te.get_width()-20,self.te.get_height()-20))
  656. self.rect = pygame.Rect(x,y,height,width)
  657. def draw(self):
  658. self.rect.topleft = (self.x,self.y)
  659. window.blit(self.te,self.rect)
  660. pygame.draw.rect(window,self.color,self.rect)
  661. # define text class
  662. black = (0,0,0)
  663. text1 = texto(50,100,50,50,black)
  664. texting = [text1]
  665.  
  666.  
  667. # house image
  668. housee = pygame.image.load("house.png")
  669. # house
  670. class house:
  671. def __init__(self,x,y,height,width,color):
  672. self.x = x
  673. self.y =y
  674. self.height = height
  675. self.width = width
  676. self.color = color
  677. self.housee = pygame.image.load("house.png")
  678. self.rect = pygame.Rect(x,y,height,width)
  679. def draw(self):
  680. self.rect.topleft = (self.x,self.y)
  681. window.blit(self.housee,self.rect)
  682. # define the house class
  683. white = (255,255,255)
  684. house1 = house(50,290,60,60,white)
  685. housing = [house1]
  686. # player image
  687. man = [pygame.image.load("i1.png"),
  688. pygame.image.load("i1.png"),
  689. pygame.image.load("i2.png"),
  690. pygame.image.load("i3.png"),
  691. pygame.image.load("i4.png"),
  692. pygame.image.load("i5.png"),
  693. pygame.image.load("i6.png"),
  694. pygame.image.load("i7.png"),
  695. pygame.image.load("i8.png"),
  696. pygame.image.load("i9.png"),
  697. pygame.image.load("i10.png"),
  698. pygame.image.load("i11.png"),
  699. pygame.image.load("i12.png"),
  700. pygame.image.load("i13.png"),
  701. pygame.image.load("i14.png"),
  702. pygame.image.load("i15.png")]
  703.  
  704.  
  705.  
  706. # player villager
  707. class villager:
  708. def __init__(self,x,y,height,width,color):
  709. self.x = x
  710. self.y = y
  711. self.height = height
  712. self.width = width
  713. self.color = color
  714. self.man =[
  715. pygame.image.load("i1.png"),
  716. pygame.image.load("i1.png"),
  717. pygame.image.load("i2.png"),
  718. pygame.image.load("i3.png"),
  719. pygame.image.load("i4.png"),
  720. pygame.image.load("i5.png"),
  721. pygame.image.load("i6.png"),
  722. pygame.image.load("i7.png"),
  723. pygame.image.load("i8.png"),
  724. pygame.image.load("i9.png"),
  725. pygame.image.load("i10.png"),
  726. pygame.image.load("i11.png"),
  727. pygame.image.load("i12.png"),
  728. pygame.image.load("i13.png"),
  729. pygame.image.load("i14.png"),
  730. pygame.image.load("i15.png")]
  731. self.direction = "so"
  732. self.anim_index = 0
  733. self.so_index = 0
  734. self.man = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.man]
  735. self.rect = pygame.Rect(x,y,height,width)
  736. def draw(self):
  737. self.rect.topleft = (self.x,self.y)
  738. if self.direction == "so":
  739. window.blit(self.man[self.anim_index], self.rect)
  740.  
  741. self.anim_index += 1
  742. if self.anim_index == len(self.man):
  743. self.anim_index = 0
  744.  
  745.  
  746.  
  747. # image of the sigh
  748. sighimage = pygame.image.load("sigh.png")
  749. # level 1 sigh class
  750. class sign:
  751. def __init__(self,x,y,height,width,color):
  752. self.x = x
  753. self.y = y
  754. self.color = color
  755. self.height = height
  756. self.width = width
  757. self.sighimage = pygame.image.load("sigh.png")
  758. self.sighimage = pygame.transform.scale(self.sighimage,(self.sighimage.get_width()-10,self.sighimage.get_height()-10))
  759. self.rect = pygame.Rect(x,y,height,width)
  760. def draw(self):
  761. self.rect.topleft = (self.x,self.y)
  762. window.blit(self.sighimage,self.rect)
  763.  
  764. # define level 1 sighn
  765. black = (0,0,0)
  766. sighn1 = sign(-33,300,50,50,black)
  767. signs = [sighn1]
  768.  
  769.  
  770.  
  771. # enemy animations
  772. esleft = [pygame.image.load("esleft1.png"),
  773. pygame.image.load("esleft1.png"),
  774. pygame.image.load("esleft2.png"),
  775. pygame.image.load("esleft3.png"),
  776. pygame.image.load("esleft4.png"),
  777. pygame.image.load("esleft5.png"),
  778. pygame.image.load("esleft6.png"),
  779. pygame.image.load("esleft7.png"),
  780. pygame.image.load("esleft8.png"),
  781. pygame.image.load("esleft9.png"),
  782. pygame.image.load("esleft10.png"),
  783. pygame.image.load("esleft11.png"),
  784. pygame.image.load("esleft12.png"),
  785. pygame.image.load("esleft13.png"),
  786. pygame.image.load("esleft14.png"),
  787. pygame.image.load("esleft15.png"),
  788. pygame.image.load("esleft16.png"),
  789. pygame.image.load("esleft17.png"),
  790. ]
  791.  
  792.  
  793. esright = [pygame.image.load("esright1.png"),
  794. pygame.image.load("esright1.png"),
  795. pygame.image.load("esright2.png"),
  796. pygame.image.load("esright3.png"),
  797. pygame.image.load("esright4.png"),
  798. pygame.image.load("esright5.png"),
  799. pygame.image.load("esright6.png"),
  800. pygame.image.load("esright7.png"),
  801. pygame.image.load("esright8.png"),
  802. pygame.image.load("esright9.png"),
  803. pygame.image.load("esright10.png"),
  804. pygame.image.load("esright11.png"),
  805. pygame.image.load("esright12.png"),
  806. pygame.image.load("esright13.png"),
  807. pygame.image.load("esright14.png"),
  808. pygame.image.load("esright15.png"),
  809. pygame.image.load("esright16.png"),
  810. pygame.image.load("esright17.png"),
  811. ]
  812.  
  813.  
  814. class enemys:
  815. def __init__(self,x,y,height,width,end):
  816. self.x = x
  817. self.y =y
  818. self.esright = [pygame.image.load("esright1.png"),
  819. pygame.image.load("esright1.png"),
  820. pygame.image.load("esright2.png"),
  821. pygame.image.load("esright3.png"),
  822. pygame.image.load("esright4.png"),
  823. pygame.image.load("esright5.png"),
  824. pygame.image.load("esright6.png"),
  825. pygame.image.load("esright7.png"),
  826. pygame.image.load("esright8.png"),
  827. pygame.image.load("esright9.png"),
  828. pygame.image.load("esright10.png"),
  829. pygame.image.load("esright11.png"),
  830. pygame.image.load("esright12.png"),
  831. pygame.image.load("esright13.png"),
  832. pygame.image.load("esright14.png"),
  833. pygame.image.load("esright15.png"),
  834. pygame.image.load("esright16.png"),
  835. pygame.image.load("esright17.png"),
  836. ]
  837. self.esleft = [pygame.image.load("esleft1.png"),
  838. pygame.image.load("esleft1.png"),
  839. pygame.image.load("esleft2.png"),
  840. pygame.image.load("esleft3.png"),
  841. pygame.image.load("esleft4.png"),
  842. pygame.image.load("esleft5.png"),
  843. pygame.image.load("esleft6.png"),
  844. pygame.image.load("esleft7.png"),
  845. pygame.image.load("esleft8.png"),
  846. pygame.image.load("esleft9.png"),
  847. pygame.image.load("esleft10.png"),
  848. pygame.image.load("esleft11.png"),
  849. pygame.image.load("esleft12.png"),
  850. pygame.image.load("esleft13.png"),
  851. pygame.image.load("esleft14.png"),
  852. pygame.image.load("esleft15.png"),
  853. pygame.image.load("esleft16.png"),
  854. pygame.image.load("esleft17.png"),
  855. ]
  856. self.esright = [pygame.transform.scale(image,(image.get_width()//3,image.get_height()//3)) for image in self.esright]
  857. self.esleft = [pygame.transform.scale(image,(image.get_width()//3,image.get_height()//3)) for image in self.esleft]
  858. self.height = height
  859. self.width = width
  860. self.anim_index = 0
  861. self.distance = 80
  862. self.speed = 8
  863. self.vel = 3
  864. self.path = [x,end]
  865. self.Walking_index = 0
  866. self.hitbox = (self.x + 17, self.y + 2, 31, 57)
  867. self.rect = pygame.Rect(x,y,height,width)
  868. COOLDOWN = 30
  869. # enemys health
  870. self.health = 10
  871. self.visible = True
  872.  
  873. # this makes the enemy move right and left
  874. def draw(self,window):
  875. self.move()
  876. if self.Walking_index + 1 >= 33:
  877. self.Walking_index = 0
  878. if self.vel > 0:
  879. window.blit(self.esright[self.Walking_index//3], (self.x,self.y))
  880. self.Walking_index += 1
  881. else:
  882. window.blit(self.esleft[self.Walking_index//3], (self.x,self.y))
  883. self.Walking_index += 1
  884.  
  885. # this moves the enemy left and right
  886. def move(self):
  887. if self.visible:
  888. if self.vel > 0:
  889. if self.x + self.vel < self.path[1]:
  890. self.x += self.vel
  891. else:
  892. self.vel = self.vel * -1
  893. self.Walking_index = 0
  894. else:
  895. if self.x - self.vel > self.path[0]:
  896. self.x += self.vel
  897. else:
  898. self.vel = self.vel * -1
  899. self.Walking_index = 0
  900. # the hit box for the enemy the health
  901. pygame.draw.rect(window, (255,0,0), (self.hitbox[0], self.hitbox[1] - 20, 70, 10)) # NEW
  902. pygame.draw.rect(window, (0,255,0), (self.hitbox[0], self.hitbox[1] - 20, 70 - (5 * (10 - self.health)), 10))
  903. self.hitbox = (self.x + 47, self.y + 31, 50, 72)
  904.  
  905.  
  906. # THIS PART MAKES the enemy not scroll with the player
  907. def scroll(self,sx, sy):
  908. self.x += sx
  909. self.y += sy
  910. self.path[0] += sx
  911. self.path[1] += sx
  912.  
  913.  
  914.  
  915. #-----------------------------------------------------------------------------------------------------
  916.  
  917. smallice = pygame.image.load("fals.png")
  918. class smallice:
  919. def __init__(self,x,y,height,width,color):
  920. self.x = x
  921. self.y = y
  922. self.height = height
  923. self.width = width
  924. self.color = color
  925. self.smallice = pygame.image.load("fals.png")
  926. self.smallice = pygame.transform.scale(self.smallice,(self.smallice.get_width()-2,self.smallice.get_height()-2))
  927. self.rect = pygame.Rect(x,y,height,width)
  928. self.hits = (self.x + 20, self.y, 28,60)
  929. self.health = 10
  930. # the hitbox our projectiles will be colliding with
  931. self.hitbox = (self.x + 0, self.y + 1, 10, 72)
  932. def draw(self):
  933. self.rect.topleft = (self.x,self.y)
  934. player_rect = self.smallice.get_rect(center = self.rect.center)
  935. player_rect.centerx += 0 # 10 is just an example
  936. player_rect.centery += 70 # 15 is just an example
  937. window.blit(self.smallice, player_rect)
  938. self.hits = (self.x + 20, self.y, 28,60)
  939. pygame.draw.rect(window, (255,0,0), (self.hitbox[0], self.hitbox[1] - 60, 50, 10)) # NEW
  940. pygame.draw.rect(window, (0,255,0), (self.hitbox[0], self.hitbox[1] - 60, 50 - (5 * (10 - self.health)), 10))
  941. self.hitbox = (self.x + -20, self.y + 30, 31, 57)
  942.  
  943. # define the small ices
  944. black = (0,0,0)
  945. smallice1 = smallice(550,215,20,20,black)
  946. smallice2 = smallice(750,215,20,20,black)
  947. smallice3 = smallice(950,215,20,20,black)
  948. smallice4 = smallice(1110,215,20,20,black)
  949. small = [smallice1]
  950. smalls = [smallice2]
  951. smallss = [smallice3]
  952. smallsss = [smallice4]
  953.  
  954. # enemys bullets
  955. littleice = pygame.image.load("littleboy.png")
  956. class Bullet(object):
  957. def __init__(self, x, y,color):
  958. self.x = x
  959. self.y = y
  960. self.littleice = pygame.image.load("littleboy.png")
  961. self.hitbox = self.littleice.get_rect()
  962. self.rect = self.littleice.get_rect()
  963. self.rect.topleft = (self.x,self.y)
  964. self.speed = 10
  965. self.color = color
  966. self.hitbox = (self.x + 57, self.y + 33, 29, 52) # NEW
  967. def draw(self, window):
  968. self.rect.topleft = (self.x,self.y)
  969. player_rect = self.littleice.get_rect(center = self.rect.center)
  970. player_rect.centerx += 0 # 10 is just an example
  971. player_rect.centery += 0 # 15 is just an example
  972. window.blit(self.littleice, player_rect)
  973. self.hitbox = (self.x + 97, self.y + 33, 10, 10) # NEW
  974. window.blit(self.littleice,self.rect)
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981. #---------------------------------------------------------------------------------------------
  982.  
  983.  
  984.  
  985.  
  986.  
  987. # position image
  988. thisispos = pygame.image.load("poslol.png")
  989. # poisiton class health UP
  990. class pos5:
  991. def __init__(self,x,y,height,width,color):
  992. self.x = x
  993. self.y = y
  994. self.height = height
  995. self.width = width
  996. self.color = color
  997. self.thisispos = pygame.image.load("poslol.png")
  998. self.thisispos = pygame.transform.scale(self.thisispos,(self.thisispos.get_width()//8,self.thisispos.get_height()//8))
  999. self.rect = pygame.Rect(x,y,height,width)
  1000. # the hitbox our projectiles will be colliding with
  1001. self.hitbox = (self.x + 0, self.y + 1, 10, 72)
  1002. def draw(self):
  1003. self.rect.topleft = (self.x,self.y)
  1004. player_rect = self.thisispos.get_rect(center = self.rect.center)
  1005. player_rect.centerx += -10 # 10 is just an example
  1006. player_rect.centery += 29 # 15 is just an example
  1007. window.blit(self.thisispos, player_rect)
  1008. self.hitbox = (self.x + -20, self.y + 30, 21, 67)
  1009.  
  1010. # define the pos class
  1011. black = (0,0,0)
  1012. pos1 = pos5(950,390,50,50,black)
  1013. poses = [pos1]
  1014.  
  1015.  
  1016.  
  1017. # enemy icon image
  1018. enemyi = pygame.image.load("ei.png")
  1019. # enemy icon class
  1020. class enemyicon:
  1021. def __init__(self,x,y,height,width,color):
  1022. self.x = x
  1023. self.y = y
  1024. self.height = height
  1025. self.width = width
  1026. self.color = color
  1027. self.enemyi = pygame.image.load("ei.png")
  1028. self.rect = pygame.Rect(x,y,height,width)
  1029. self.enemyi = pygame.transform.scale(self.enemyi,(self.enemyi.get_width()//3,self.enemyi.get_height()//3))
  1030. def draw(self):
  1031. self.rect.topleft = (self.x,self.y)
  1032. window.blit(self.enemyi,self.rect)
  1033.  
  1034.  
  1035.  
  1036.  
  1037. # hurt image
  1038. hurts = [pygame.image.load("HURT1.png"),
  1039. pygame.image.load("HURT2.png"),
  1040. pygame.image.load("HURT3.png"),
  1041. pygame.image.load("HURT4.png")]
  1042.  
  1043.  
  1044.  
  1045. def hurt():
  1046. delay = 105
  1047. next_frame = pygame.time.get_ticks() + delay
  1048. if pygame.time.get_ticks() >= next_frame:
  1049. next_frame = pygame.time.get_ticks() + delay
  1050. hurts = [pygame.image.load("HURT1.png"),
  1051. pygame.image.load("HURT2.png"),
  1052. pygame.image.load("HURT3.png"),
  1053. pygame.image.load("HURT4.png")]
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059. # define enemy icon class
  1060. black = (0,0,0)
  1061. enemyi1 = enemyicon(0,70,50,50,black)
  1062. enemyicons = [enemyi1]
  1063.  
  1064. # define the enemy class
  1065. black = (0,0,0)
  1066. enemys1 = enemys(400,399,104,64,500)
  1067. enemys2 = enemys(650,399,104,64,900)
  1068. enemying = [enemys1]
  1069. enemyings = [enemys2]
  1070.  
  1071.  
  1072. # define the villager class
  1073. red = (255,255,0)
  1074. villager1 = villager(150,400,20,20,red)
  1075. villaging = [villager1]
  1076.  
  1077.  
  1078. black = (0,0,0)
  1079. white = (255,255,255)
  1080. green = (0,255,0)
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086. #_------
  1087.  
  1088.  
  1089. # colors
  1090. White = (255,255,255)
  1091. Black = ((0,0,0))
  1092. Yellow = ((231,253,0))
  1093.  
  1094. # frames per second
  1095. FPS = 60
  1096. clock = pygame.time.Clock()
  1097.  
  1098.  
  1099. # define player class
  1100. playerman = player(50,450,30,30,Black)
  1101.  
  1102. # coins
  1103. coin1 = coin(340,450,30,30, Yellow)
  1104. coin2 = coin(370,450,30,30, Yellow)
  1105. coin3 = coin(370,420,30,30, Yellow)
  1106. coin4 = coin(340,420,30,30, Yellow)
  1107. coin5 = coin(480,450,30,30, Yellow)
  1108. coin6 = coin(530,450,30,30, Yellow)
  1109.  
  1110. Coins_list = [coin1,coin2,coin3,coin4,coin5,coin6]
  1111.  
  1112.  
  1113.  
  1114. # enemy base
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121. # define platforms class
  1122. plat = platform(-1000,500,6310,20,White)
  1123. platforms = [plat]
  1124. platformGroup = pygame.sprite.Group
  1125. platformList = []
  1126. level = [" ",
  1127. " t ",
  1128. " to to to ",
  1129. "p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p ",
  1130. " ",
  1131. " ",
  1132. " " ,
  1133. " b b b b b b b p ",
  1134. " s s s s ",
  1135. " b b b ",
  1136. "p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p ",]
  1137.  
  1138.  
  1139.  
  1140. for iy, row in enumerate(level):
  1141. for ix, col in enumerate(row):
  1142. if col == "p":
  1143. new_platforms = platform(ix*10, iy*50, 10,10,(255,255,255))
  1144. platforms.append(new_platforms)
  1145.  
  1146.  
  1147. for iy, row in enumerate(level):
  1148. for ix, col in enumerate(row):
  1149. if col == "s":
  1150. new_platforms = dice(ix*30, iy*50, 10,250,(255,255,255))
  1151. dicing.append(new_platforms)
  1152.  
  1153. for iy, row in enumerate(level):
  1154. for ix, col in enumerate(row):
  1155. if col == "t":
  1156. new_platforms = icess(ix*30, iy*110, 10,10,(255,255,255))
  1157. icing.append(new_platforms)
  1158. for iy, row in enumerate(level):
  1159. for ix, cols in enumerate(row):
  1160. if cols == "b":
  1161. new_platforms = bush(ix*20, iy*15, 10,10,(255,255,255))
  1162. bushes.append(new_platforms)
  1163.  
  1164.  
  1165.  
  1166. for iy, row in enumerate(level):
  1167. for ix, cols in enumerate(row):
  1168. if cols == "o":
  1169. new_platforms = tree(ix*20, iy* -20, 10,10,(255,255,255))
  1170. trees.append(new_platforms)
  1171.  
  1172.  
  1173.  
  1174.  
  1175. # enemy -5 def function call the function under the enemy thing when you hit it
  1176. def minusenemyhealthtext():
  1177. font1 = pygame.font.SysFont('BLOODY.tff', 100)
  1178. stext = font1.render('-5', 1, (255,0,0))
  1179. window.blit(stext, (450 - (stext.get_width()/2),300))
  1180. pygame.display.update()
  1181.  
  1182. # this function ads +5 when ever we drink or health potion
  1183. def plushealth():
  1184.  
  1185. font2 = pygame.font.SysFont('comicsans', 100)
  1186. sstext = font2.render('+5', 1, (0,255,0))
  1187. window.blit(sstext, (450 - (sstext.get_width()/2),200))
  1188. pygame.display.update()
  1189.  
  1190.  
  1191. # coin scoring
  1192. font = pygame.font.Font('times.ttf',29)
  1193. score = 0
  1194. text = font.render("Hearts = " + str(score), True, (255,255,255))
  1195. textRect = text.get_rect()
  1196. textRect.center = ((80,70))
  1197. #-------------------------------- enemy shoots left and right
  1198.  
  1199. shotsright = pygame.image.load("shooting2.png")
  1200. shotsleft = pygame.image.load("shooting1.png")
  1201. class enemyshoot:
  1202. def __init__(self,x,y,height,width,color):
  1203. self.x = x
  1204. self.y =y
  1205. self.height = height
  1206. self.width = width
  1207. self.color = color
  1208. self.shootsright = pygame.image.load("shooting2.png")
  1209. self.shotsleft = pygame.image.load("shooting1.png")
  1210. self.shootsright = pygame.transform.scale(self.shootsright,(self.shootsright.get_width()//3,self.shootsright.get_height()//3))
  1211. self.shotsleft = pygame.transform.scale(self.shotsleft,(self.shotsleft.get_width()//3,self.shotsleft.get_height()//3))
  1212.  
  1213. self.rect = pygame.Rect(x,y,height,width)
  1214. self.health = 10
  1215. self.hitbox = (self.x + -20, self.y + 30, 31, 57)
  1216. def draw(self):
  1217. self.rect.topleft = (self.x,self.y)
  1218. window.blit(self.shootsright,self.rect)
  1219. self.hits = (self.x + 20, self.y, 28,60)
  1220. pygame.draw.rect(window, (255,0,0), (self.hitbox[0], self.hitbox[1] - 60, 50, 10)) # NEW
  1221. pygame.draw.rect(window, (0,255,0), (self.hitbox[0], self.hitbox[1] - 60, 50 - (5 * (10 - self.health)), 10))
  1222. self.hitbox = (self.x + 60, self.y + 80, 81, 87)
  1223.  
  1224. black = (0,0,0)
  1225. enemyshoots1 = enemyshoot(1100,240,100,100,black)
  1226. enemyshooting = [enemyshoots1]
  1227.  
  1228. #------------------------------------------------------------------------------
  1229. # enemys bullets
  1230. ksud = pygame.image.load("heart.png")
  1231. class Bools(object):
  1232. def __init__(self, x, y,color):
  1233. self.x = x
  1234. self.y = y
  1235. self.ksud = pygame.image.load("heart.png")
  1236. self.hitbox = self.ksud.get_rect()
  1237. self.rect = self.ksud.get_rect()
  1238. self.rect.topleft = (self.x,self.y)
  1239. self.speed = 10
  1240. self.color = color
  1241. self.hitbox = (self.x + 57, self.y + 33, 29, 52) # NEW
  1242. def draw(self, window):
  1243. self.rect.topleft = (self.x,self.y)
  1244. player_rect = self.ksud.get_rect(center = self.rect.center)
  1245. player_rect.centerx += 0 # 10 is just an example
  1246. player_rect.centery += 0 # 15 is just an example
  1247. window.blit(self.ksud, player_rect)
  1248. self.hitbox = (self.x + 97, self.y + 33, 10, 10) # NEW
  1249. window.blit(self.ksud,self.rect)
  1250.  
  1251.  
  1252.  
  1253.  
  1254. #------------------------------------------------------------------------------
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260. # varabile for image text sighns
  1261. # main game loop
  1262. shootsright = []
  1263. bullets = []
  1264. bulls = []
  1265. bullss = []
  1266. bullsss = []
  1267. bullssss = []
  1268. runninggame = True
  1269. while runninggame:
  1270. clock.tick(FPS)
  1271. for event in pygame.event.get():
  1272. if event.type == pygame.QUIT:
  1273. runninggame = False
  1274.  
  1275.  
  1276.  
  1277.  
  1278. # -------- shoot the bullets when you click your mouse
  1279.  
  1280.  
  1281. if event.type == pygame.MOUSEBUTTONDOWN:
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287. # this is for the bullets
  1288. if len(bullets) < 2:
  1289. shootsound.play()
  1290.  
  1291. start_x, start_y = playerman.x+playerman.width//2, playerman.y + playerman.height-54
  1292. mouse_x, mouse_y = event.pos
  1293.  
  1294. dir_x, dir_y = mouse_x - start_x, mouse_y - start_y
  1295. distance = math.sqrt(dir_x**2 + dir_y**2)
  1296. if distance > 0:
  1297. new_bullet = projectile(start_x, start_y, dir_x/distance, dir_y/distance, (0,0,0))
  1298. bullets.append(new_bullet)
  1299. # this is displaying the bullets for the player
  1300. for bullet in bullets[:]:
  1301. bullet.move()
  1302. if bullet.x < 0 or bullet.x > 900 or bullet.y < 0 or bullet.y > 900:
  1303. bullets.pop(bullets.index(bullet))
  1304.  
  1305. #--------------------------------------------------------------------------------------------------------- enemys
  1306.  
  1307. # enemys 1
  1308. for bullet in bullets:
  1309. if bullet.rect.colliderect(enemys2.hitbox):
  1310. if enemys2.health > -5:
  1311. enemys2.health -= 1
  1312. bullets.pop(bullets.index(bullet))
  1313. hitesound.play()
  1314. # this function calss the -5 text appearing and dispearing on my screen
  1315. minusenemyhealthtext()
  1316. else:
  1317. for oe in range(len(enemyings)-1,-1,-1):
  1318. deathsound.play()
  1319. del enemyings[oe]
  1320.  
  1321. # enemys 2
  1322. for bullet in bullets:
  1323. if bullet.rect.colliderect(enemys1.hitbox):
  1324. if enemys1.health > -5:
  1325. enemys1.health -= 1
  1326. bullets.pop(bullets.index(bullet))
  1327. hitesound.play()
  1328. # this function calss the -5 text appearing and dispearing on my screen
  1329. minusenemyhealthtext()
  1330. else:
  1331. for one in range(len(enemying)-1,-1,-1):
  1332. deathsound.play()
  1333. del enemying[one]
  1334.  
  1335.  
  1336.  
  1337. #---------------------------------------------------------------------------------------------------------
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344. # if collides with the sharp tiles
  1345. for bullet in bullets:
  1346. for icess in icing:
  1347. if bullet.rect.colliderect(icess.hitbox):
  1348. bullets.pop(bullets.index(bullet))
  1349. icesound.play()
  1350. print("YO YOU COLLIDED THAT SHIT")
  1351. for bullet in bullets:
  1352. for dice in dicing:
  1353. if bullet.rect.colliderect(dice.hitbox):
  1354. bullets.pop(bullets.index(bullet))
  1355. icesound.play()
  1356. print("yo fam you collided with that sharp thing")
  1357.  
  1358.  
  1359.  
  1360. # health players
  1361. for dice in dicing:
  1362. if playerman.rect.colliderect(dice.hitbox):
  1363. hurtsound.play()
  1364. if playerman.health > -6:
  1365. playerman.health -= 1
  1366. playerman.x = 10
  1367.  
  1368.  
  1369. else:
  1370. print("cant delete him")
  1371.  
  1372.  
  1373.  
  1374. for pos5 in poses:
  1375. if playerman.rect.colliderect(pos5.hitbox):
  1376. healthsound.play()
  1377. playerman.health += 5
  1378. del poses[one]
  1379. # this function loads +5 for the player
  1380. plushealth()
  1381.  
  1382. # ----------------------------------------------------------------------------
  1383. # collision between the ices
  1384.  
  1385. for bullet in bullets:
  1386. for bull in bulls:
  1387. for smallice in small:
  1388. if bullet.rect.colliderect(smallice.rect):
  1389. icesound.play()
  1390. if smallice.health > 1:
  1391. smallice.health -= 1
  1392.  
  1393. else:
  1394. del small[one]
  1395. if bull.y < 1050 and bull.y > 2160:
  1396. print("by by mfs")
  1397.  
  1398.  
  1399.  
  1400.  
  1401. # collision between the ices
  1402.  
  1403. for bullet in bullets:
  1404. for firstb in bullss:
  1405. for smallice in smalls:
  1406. if bullet.rect.colliderect(smallice.rect):
  1407. icesound.play()
  1408. if smallice.health > 1:
  1409. smallice.health -= 1
  1410.  
  1411. else:
  1412. del smalls[one]
  1413. if firstb.y < 1050 and firstb.y > 2160:
  1414. print("by by mfs")
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420. # collision between the ices
  1421.  
  1422. for bullet in bullets:
  1423. for secondb in bullsss:
  1424. for smallice in smallss:
  1425. if bullet.rect.colliderect(smallice.rect):
  1426. icesound.play()
  1427. if smallice.health > 1:
  1428. smallice.health -= 1
  1429.  
  1430. else:
  1431. del smallss[one]
  1432. if secondb.y < 1050 and secondb.y > 2160:
  1433. print("by by mfs")
  1434.  
  1435.  
  1436.  
  1437. # collision between the ices
  1438.  
  1439. for bullet in bullets:
  1440. for thirdb in bullssss:
  1441. for smallice in smallsss:
  1442. if bullet.rect.colliderect(smallice.rect):
  1443. icesound.play()
  1444. if smallice.health > 1:
  1445. smallice.health -= 1
  1446.  
  1447. else:
  1448. del smallsss[one]
  1449. if thirdb.y < 1050 and thirdb.y > 2160:
  1450. print("by by mfs")
  1451.  
  1452. # ----------------------------------------------------------------------------
  1453. # collision between the ices
  1454.  
  1455. #Poping bullets from list
  1456.  
  1457.  
  1458. for bull in bulls:
  1459. if playerman.rect.colliderect(bull.hitbox):
  1460. playerman.health -=1
  1461. bulls.pop(bulls.index(bull))
  1462.  
  1463.  
  1464. for firstb in bullss:
  1465. if playerman.rect.colliderect(firstb.hitbox):
  1466. playerman.health -=1
  1467. bullss.pop(bullss.index(firstb))
  1468.  
  1469.  
  1470.  
  1471. for secondb in bullsss:
  1472. if playerman.rect.colliderect(secondb.hitbox):
  1473. playerman.health -=1
  1474. bullsss.pop(bullsss.index(secondb))
  1475.  
  1476.  
  1477.  
  1478.  
  1479. for thirdb in bullssss:
  1480. if playerman.rect.colliderect(thirdb.hitbox):
  1481. playerman.health -=1
  1482. bullssss.pop(bullssss.index(thirdb))
  1483.  
  1484.  
  1485.  
  1486.  
  1487. #---------------------------------------------------------------------------------------------------------------------------------------------
  1488. # projectile class for each of the bullets
  1489. for bull in bulls:
  1490. if bull.y < 550 and bull.y > 0:
  1491. bull.y += 4
  1492. else:
  1493. bulls.pop(bulls.index(bull))
  1494. if len(bulls) < 1:
  1495. bulls.append(Bullet(round(smallice1.x+smallice1.width-107),round(smallice1.y + smallice1.height-50),(0,0,0)))
  1496.  
  1497. for firstb in bullss:
  1498. if firstb.y < 550 and bull.y > 0:
  1499. firstb.y += 5
  1500. else:
  1501. bullss.pop(bullss.index(firstb))
  1502. if len(bullss) < 1:
  1503. bullss.append(Bullet(round(smallice2.x+smallice2.width-107),round(smallice2.y + smallice2.height-50),(0,0,0)))
  1504.  
  1505. for secondb in bullsss:
  1506. if secondb.y < 550 and secondb.y > 0:
  1507. secondb.y += 6
  1508. else:
  1509. bullsss.pop(bullsss.index(secondb))
  1510. if len(bullsss) < 1:
  1511. bullsss.append(Bullet(round(smallice3.x+smallice3.width-107),round(smallice3.y + smallice3.height-50),(0,0,0)))
  1512.  
  1513.  
  1514. for thirdb in bullssss:
  1515. if thirdb.y < 550 and thirdb.y > 0:
  1516. thirdb.y += 7
  1517. else:
  1518. bullssss.pop(bullssss.index(thirdb))
  1519. if len(bullssss) < 1:
  1520. bullssss.append(Bullet(round(smallice4.x+smallice4.width-107),round(smallice4.y + smallice4.height-50),(0,0,0)))
  1521.  
  1522. for shootss in shootsright:
  1523. if shootss.x < 500 and shootss.x > 0:
  1524. shootss.x += 7
  1525. else:
  1526. shootsright.pop(shootsright.index(shootss))
  1527. if len(shootsright) < 1:
  1528. shootsright.append(Bools(round(enemyshoots1.x+enemyshoots1.width-107),round(enemyshoots1.y + enemyshoots1.height-50),(0,0,0)))
  1529.  
  1530.  
  1531.  
  1532. # projectile class for each of the bullets
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538. #---------------------------------------------------------------------------------------------------------------------------------------------
  1539. keys = pygame.key.get_pressed()
  1540.  
  1541.  
  1542.  
  1543.  
  1544. # Jump and Collisions
  1545.  
  1546.  
  1547. # camera left and right movement
  1548. if playerman.y < 250:
  1549. playerman.y += 1
  1550. for platform in platforms:
  1551. platform.y += playerman.speed
  1552. for coin in Coins_list:
  1553. coin.y += playerman.speed
  1554. for error in errors:
  1555. error.y += playerman.speed
  1556. for dice in dicing:
  1557. dice.y += playerman.speed
  1558. for icess in icing:
  1559. icess.y += playerman.speed
  1560. for bush in bushes:
  1561. bush.y += playerman.speed
  1562. for spie in spies:
  1563. spie.y += playerman.speed
  1564. for Snow in snowing:
  1565. Snow.y += playerman.speed
  1566. for alrt in alerting:
  1567. alrt.y += playerman.speed
  1568. for villager in villaging:
  1569. villager.y += playerman.speed
  1570. for house in housing:
  1571. house.y += playerman.speed
  1572. for tree in trees:
  1573. tree.y += playerman.speed
  1574. for sign in signs:
  1575. sign.y += playerman.speed
  1576. for pos5 in poses:
  1577. pos5.y += playerman.speed
  1578. for smallice in small:
  1579. smallice.y += playerman.speed
  1580.  
  1581. for enemyshoot in enemyshooting:
  1582. enemyshoot.y += playerman.speed
  1583.  
  1584. #--------------------------------------------------------
  1585. # bullets for ice falling camera control
  1586.  
  1587. for bull in bulls:
  1588. bull.y += playerman.speed
  1589. for firstb in bullss:
  1590. firstb.y += playerman.speed
  1591. for secondb in bullsss:
  1592. secondb.y += playerman.speed
  1593. for thirdb in bullssss:
  1594. thirdb.y += playerman.speed
  1595.  
  1596.  
  1597. #----------------------------------------------
  1598. # the ice fallings camera cdontrol
  1599. for smallice in smalls:
  1600. smallice.y += playerman.speed
  1601. for smallice in smallss:
  1602. smallice.y += playerman.speed
  1603. for smallice in smallsss:
  1604. smallice.y += playerman.speed
  1605.  
  1606. #----------------------------------------------
  1607.  
  1608.  
  1609.  
  1610.  
  1611. for enemys in enemying:
  1612. enemys.scroll(0,+ playerman.speed)
  1613.  
  1614.  
  1615.  
  1616. for enemys in enemyings:
  1617. enemys.scroll(0,+ playerman.speed)
  1618.  
  1619.  
  1620. for shootss in shootsright:
  1621. shootss.y += playerman.speed
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631. # camera up movement:
  1632. if playerman.y > 500:
  1633. playerman.y -= playerman.fall
  1634. for platform in platforms:
  1635. platform.y -= playerman.fall
  1636. for coin in Coins_list:
  1637. coin.y -= playerman.fall
  1638. for error in errors:
  1639. error.y -= playerman.fall
  1640. for dice in dicing:
  1641. dice.y -= playerman.fall
  1642. for icess in icing:
  1643. icess.y -= playerman.fall
  1644. for bush in bushes:
  1645. bush.y -= playerman.fall
  1646. for spie in spies:
  1647. spie.y -= playerman.fall
  1648. for Snow in snowing:
  1649. Snow.y -= playerman.fall
  1650. for villager in villaging:
  1651. villager.y -= playerman.fall
  1652. for house in housing:
  1653. house.y -= playerman.fall
  1654. for alrt in alerting:
  1655. alrt.y -= playerman.fall
  1656. for tree in trees:
  1657. tree.y -= playerman.fall
  1658. for sign in signs:
  1659. sign.y -= playerman.fall
  1660. for pos5 in poses:
  1661. pos5.y -= playerman.fall
  1662. for enemyshoot in enemyshooting:
  1663. enemyshoot.y -= playerman.fall
  1664.  
  1665.  
  1666. #----------------------------------------------
  1667.  
  1668.  
  1669. for smallice in small:
  1670. smallice.y -= playerman.fall
  1671.  
  1672. for smallice in smalls:
  1673. smallice.y -= playerman.fall
  1674. for smallice in smallss:
  1675. smallice.y -= playerman.fall
  1676. for smallice in smallsss:
  1677. smallice.y -= playerman.fall
  1678.  
  1679.  
  1680. #----------------------------------------------
  1681. # camera controlf for falling ice
  1682. for bull in bulls:
  1683. bull.y -= playerman.fall
  1684.  
  1685. for firstb in bullss:
  1686. firstb.y -= playerman.fall
  1687. for secondb in bullsss:
  1688. secondb.y -= playerman.fall
  1689. for thirdb in bullssss:
  1690. thirdb.y -= playerman.fall
  1691.  
  1692.  
  1693. #----------------------------------------------
  1694.  
  1695.  
  1696.  
  1697.  
  1698. for enemys in enemying:
  1699. enemys.scroll(0, -playerman.fall)
  1700.  
  1701. for enemys in enemyings:
  1702. enemys.scroll(0, -playerman.fall)
  1703.  
  1704.  
  1705.  
  1706. for shootss in shootsright:
  1707. shootss.y -= playerman.fall
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714. keys = pygame.key.get_pressed()
  1715.  
  1716. # key binds for the player
  1717. if keys[pygame.K_a]:
  1718. playerman.x -= playerman.speed
  1719. playerman.direction = "left"
  1720. # camera controll for left
  1721. if playerman.x < 100:
  1722. playerman.x += playerman.speed
  1723. for platform in platforms:
  1724. platform.x += playerman.speed
  1725. for coin in Coins_list:
  1726. coin.x += playerman.speed
  1727. for error in errors:
  1728. error.x += playerman.speed
  1729. for dice in dicing:
  1730. dice.x += playerman.speed
  1731. for icess in icing:
  1732. icess.x += playerman.speed
  1733. for bush in bushes:
  1734. bush.x += playerman.speed
  1735. for spie in spies:
  1736. spie.x += playerman.speed
  1737. for Snow in snowing:
  1738. Snow.x += playerman.speed
  1739. for villager in villaging:
  1740. villager.x += playerman.speed
  1741. for house in housing:
  1742. house.x += playerman.speed
  1743. for alrt in alerting:
  1744. alrt.x += playerman.speed
  1745. for tree in trees:
  1746. tree.x += playerman.speed
  1747. for sign in signs:
  1748. sign.x += playerman.speed
  1749. for pos5 in poses:
  1750. pos5.x += playerman.speed
  1751. for enemyshoot in enemyshooting:
  1752. enemyshoot.x += playerman.speed
  1753.  
  1754. for shootss in shootsright:
  1755. shootss.x += playerman.speed
  1756.  
  1757. #----------------------------------------------
  1758. # the ice fallings camera cdontrol
  1759. for smallice in small:
  1760. smallice.x += playerman.speed
  1761. for smallice in smalls:
  1762. smallice.x += playerman.speed
  1763. for smallice in smallss:
  1764. smallice.x += playerman.speed
  1765. for smallice in smallsss:
  1766. smallice.x += playerman.speed
  1767. #----------------------------------------------
  1768.  
  1769.  
  1770. for bull in bulls:
  1771. bull.x += playerman.speed
  1772. for firstb in bullss:
  1773. firstb.x += playerman.speed
  1774. for secondb in bullsss:
  1775. secondb.x += playerman.speed
  1776. for thirdb in bullssss:
  1777. thirdb.x += playerman.speed
  1778. #----------------------------------------------
  1779.  
  1780.  
  1781.  
  1782.  
  1783. for enemys in enemying:
  1784. enemys.scroll(playerman.speed,0)
  1785. for enemys in enemyings:
  1786. enemys.scroll(playerman.speed,0)
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793. elif keys[pygame.K_d]:
  1794. playerman.x += playerman.speed
  1795. playerman.direction = "right"
  1796. # camera for right:
  1797. if playerman.x > 400:
  1798. playerman.x -= playerman.speed
  1799. for platform in platforms:
  1800. platform.x -= playerman.speed
  1801. for coin in Coins_list:
  1802. coin.x -= playerman.speed
  1803. for error in errors:
  1804. error.x -= playerman.speed
  1805. for dice in dicing:
  1806. dice.x -= playerman.speed
  1807. for icess in icing:
  1808. icess.x -= playerman.speed
  1809. for bush in bushes:
  1810. bush.x -= playerman.speed
  1811. for spie in spies:
  1812. spie.x -= playerman.speed
  1813. for Snow in snowing:
  1814. Snow.x -= playerman.speed
  1815. for villager in villaging:
  1816. villager.x -= playerman.speed
  1817. for house in housing:
  1818. house.x -= playerman.speed
  1819. for alrt in alerting:
  1820. alrt.x -= playerman.speed
  1821. for tree in trees:
  1822. tree.x -= playerman.speed
  1823. for sign in signs:
  1824. sign.x -= playerman.speed
  1825. for pos5 in poses:
  1826. pos5.x -= playerman.speed
  1827.  
  1828. for enemyshoot in enemyshooting:
  1829. enemyshoot.x -= playerman.speed
  1830.  
  1831. for shootss in shootsright:
  1832. shootss.x -= playerman.speed
  1833. #----------------------------------------------
  1834. # the ice fallings camera cdontrol
  1835.  
  1836. for smallice in small:
  1837. smallice.x -= playerman.speed
  1838. for smallice in smalls:
  1839. smallice.x -= playerman.speed
  1840. for smallice in smallss:
  1841. smallice.x -= playerman.speed
  1842. for smallice in smallsss:
  1843. smallice.x -= playerman.speed
  1844.  
  1845. #----------------------------------------------
  1846.  
  1847.  
  1848.  
  1849. #----------------------------------------------
  1850.  
  1851. for bull in bulls:
  1852. bull.x -= playerman.speed
  1853. for firstb in bullss:
  1854. firstb.x -= playerman.speed
  1855. for secondb in bullsss:
  1856. secondb.x -= playerman.speed
  1857. for thirdb in bullssss:
  1858. thirdb.x -= playerman.speed
  1859.  
  1860. #----------------------------------------------
  1861.  
  1862. for enemys in enemying:
  1863. enemys.scroll(-playerman.speed, 0)
  1864.  
  1865. for enemys in enemyings:
  1866. enemys.scroll(-playerman.speed, 0)
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872. else:
  1873. if playerman.direction == "right":
  1874. playerman.direction = "standright"
  1875. else:
  1876. if playerman.direction == "left":
  1877. playerman.direction = "standleft"
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883. if not playerman.isJump:
  1884. playerman.y += playerman.fall
  1885. playerman.fall += 1
  1886. collide = False
  1887. playerman.isJump = False
  1888. for platform in platforms:
  1889. if playerman.rect.colliderect(platform.rect):
  1890. collide = True
  1891. isJump = False
  1892. playerman.y = platform.rect.top - playerman.height + 1
  1893. if playerman.rect.right > platform.rect.left and playerman.rect.left < platform.rect.left - playerman.width:
  1894. playerman.x = platform.rect.left - playerman.width
  1895. if playerman.rect.left < platform.rect.right and playerman.rect.right > platform.rect.right + playerman.width:
  1896. playerman.x = platform.rect.right
  1897.  
  1898.  
  1899.  
  1900. for one in range(len(Coins_list)-1,-1,-1):
  1901. if playerman.rect.colliderect(Coins_list[one].rect):
  1902. coinsound.play()
  1903. del Coins_list[one]
  1904. score += 1
  1905. text = font.render("Hearts = " + str(score), True, (255,255,255))
  1906. textRect.center = ((80,70))
  1907.  
  1908.  
  1909.  
  1910. if collide:
  1911. if keys[pygame.K_SPACE]:
  1912. jumpsound.play()
  1913. playerman.isJump = True
  1914. playerman.fall = 0
  1915. else:
  1916. if playerman.JumpCount >= 0:
  1917. playerman.y -= (playerman.JumpCount*abs(playerman.JumpCount))*0.3
  1918. playerman.JumpCount -= 1
  1919. else:
  1920. playerman.isJump = False
  1921. playerman.JumpCount = 10
  1922.  
  1923.  
  1924. # display the player and the screen
  1925. window.fill((106, 237, 249))
  1926. window.blit(bg,(0,0))
  1927.  
  1928. for pos5 in poses:
  1929. pos5.draw()
  1930. for spie in spies:
  1931. spie.draw()
  1932. for tree in trees:
  1933. tree.draw()
  1934. for bush in bushes:
  1935. bush.draw()
  1936. for icess in icing:
  1937. icess.draw()
  1938. for dice in dicing:
  1939. dice.draw()
  1940. for Snow in snowing:
  1941. Snow.draw()
  1942. for sign in signs:
  1943. sign.draw()
  1944. for error in errors:
  1945. error.draw()
  1946. for house in housing:
  1947. house.draw()
  1948. playerman.draw()
  1949. for coin in Coins_list:
  1950. coin.draw()
  1951. for platform in platforms:
  1952. platform.draw()
  1953.  
  1954.  
  1955. for enemys in enemying:
  1956. enemys.draw(window)
  1957. for enemys in enemyings:
  1958. enemys.draw(window)
  1959.  
  1960. for villager in villaging:
  1961. villager.draw()
  1962.  
  1963. for enemyicon in enemyicons:
  1964. enemyicon.draw()
  1965. for alrt in alerting:
  1966. alrt.draw()
  1967.  
  1968.  
  1969.  
  1970.  
  1971. # draw the falling icy
  1972. for smallice in small:
  1973. smallice.draw()
  1974. for smallice in smalls:
  1975. smallice.draw()
  1976. for smallice in smallss:
  1977. smallice.draw()
  1978. for smallice in smallsss:
  1979. smallice.draw()
  1980.  
  1981. #---------------------------------------
  1982. # draw the falling bullets
  1983. for bull in bulls:
  1984. bull.draw(window)
  1985.  
  1986. for firstb in bullss:
  1987. firstb.draw(window)
  1988.  
  1989. for secondb in bullsss:
  1990. secondb.draw(window)
  1991.  
  1992. for thirdb in bullssss:
  1993. thirdb.draw(window)
  1994.  
  1995. for enemyshoot in enemyshooting:
  1996. enemyshoot.draw()
  1997.  
  1998. #---------------------------------------
  1999.  
  2000.  
  2001. for bullet in bullets:
  2002. bullet.draw(window)
  2003.  
  2004.  
  2005. for shootss in shootsright:
  2006. shootss.draw(window)
  2007.  
  2008.  
  2009. window.blit(text,textRect)
  2010.  
  2011.  
  2012. pygame.display.update()
  2013.  
  2014.  
  2015.  
  2016. pygame.quit()
Add Comment
Please, Sign In to add comment