Advertisement
Guest User

power.py

a guest
May 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. class power():
  2.  
  3. def dash():
  4.  
  5. def calcspeed(d):
  6. if abs(d) < 0.5:
  7. if d > 0:
  8. d = 1
  9. else:
  10. d = -1
  11. return (5*current.p1.g)/abs(d)
  12.  
  13. x,y = current.p1.x+int(current.p1.scale[0]/2),current.p1.y+int(current.p1.scale[1]/2)
  14. x1,y1 = pygame.mouse.get_pos()
  15. if y1 >= current.p1.y:
  16. boom = True
  17. else:
  18. boom = False
  19. try:
  20. dir = (y1-y)/(x1-x)
  21. speed = calcspeed(dir)
  22. if x1 < current.p1.x+int(current.p1.scale[0]/2):
  23. speed *= -1
  24. except:
  25. if y1 == current.p1.y:
  26. if x1 < current.p1.x+int(current.p1.scale[0]/2):
  27. dir = 'droite'
  28. else:
  29. dir = 'gauche'
  30. speed = 0
  31. else:
  32. if y1 < current.p1.y+int(current.p1.scale[1]/2):
  33. dir = 'bas'
  34. else:
  35. dir = 'haut'
  36. speed = 0
  37.  
  38. current.p1.y += current.p1.g + 2
  39. current.p1.action.append(('dash',dir,speed,boom))
  40.  
  41. def dashdamage(boom):
  42. AOE = (current.p1.x-100+int(current.p1.scale[0]/2), current.p1.y-100+int(current.p1.scale[1]/2), 200, 200)
  43. multy = 20
  44. if boom:
  45. multy *= 2.2
  46. dmg = multy*current.p1.lastgactual
  47.  
  48. for m in current.mobs:
  49. if colision(AOE, m.rect):
  50. m.life -= dmg
  51.  
  52. def soulabsorber():
  53. x,y = current.p1.x+int(current.p1.scale[0]/2),current.p1.y+int(current.p1.scale[1]/2)
  54. AOE = (x-250, y-250, 500, 500)
  55.  
  56. for m in current.mobs:
  57. if colision(AOE, m.rect):
  58. m.IA = False
  59. m.action.append(('no IA',5*60))
  60.  
  61. class sheep():
  62.  
  63. def __init__(self,x,y,dim,type):
  64. self.x = x
  65. self.y = y
  66. self.scale = dim
  67. self.img = pygame.transform.scale(pygame.image.load('texture\\mob\\sheep\\'+type+'.png').convert_alpha(),self.scale)
  68. if current.p1.imgdir == 'droite':
  69. self.dir = 1
  70. else:
  71. self.dir =-1
  72. self.img = pygame.transform.flip(self.img,True,False)
  73. self.type = type
  74. self.speed = 4
  75. self.g = 4
  76. self.gaccé = 1.05
  77. self.gm = self.g
  78. self.gactual = self.g
  79. self.onfloor = False
  80. self.airtime = 0
  81. self.touchm = []
  82.  
  83. def move(self):
  84. power.sheep.calcgravity(self)
  85. self.x += self.dir*self.speed
  86. self.y += self.gactual
  87. self.rect = (self.x,self.y,self.scale[0],self.scale[1])
  88.  
  89. def calcgravity(self):
  90. self.gactual = int(self.gm + self.gaccé*self.airtime)
  91. if self.onfloor:
  92. self.airtime = 0
  93. else:
  94. self.airtime += 1
  95.  
  96. def contact(self):
  97. for m in current.mobs:
  98. if colision(self.rect, m.rect):
  99. if self.type == 'explosif':
  100. m.life -= 1500
  101. for i in range(20):
  102. current.particules.append(particule((int((m.x+self.x+self.scale[0])/2),int((m.y+self.y+self.scale[1])/2)),(50,50,50),True,20,5))
  103. current.p1.invoc.remove(self)
  104. if self.type == 'burn' and not(m in self.touchm):
  105. m.action.append(('burn',5,4 * 60))
  106. self.touchm.append(m)
  107. if self.type == 'eater'and not(m in self.touchm):
  108. m.life -= 500
  109. self.touchm.append(m)
  110.  
  111. def loop(lst):
  112. for mouton in lst:
  113. power.sheep.move(mouton)
  114. power.sheep.contact(mouton)
  115. fen1.blit(mouton.img, (mouton.x, mouton.y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement