Advertisement
Guest User

wall_class.py

a guest
May 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. class wall():
  2.  
  3. def __init__(self, x, y, dim, c, screen):
  4. self.x = x
  5. self.y = y
  6. self.dim = dim
  7. self.color = c
  8. self.screen = screen
  9. self.rect = (x, y, dim[0], dim[1])
  10.  
  11. def affiche(self):
  12. pygame.draw.rect(self.screen,self.color,((self.x,self.y),self.dim))
  13. self.rect = (self.x,self.y,self.dim[0],self.dim[1])
  14.  
  15. def colision(self, onfloorlist, p):
  16. p.onfloor = False
  17. entrex = p.x + p.scale[0] >= self.x + p.speed and p.x <= self.x + self.dim[0] - p.speed
  18.  
  19. if entrex and p.y + p.scale[1] + p.gactual >= self.y and p.y <= self.y + int(self.dim[1]/2):
  20. p.y = self.y - p.scale[1]
  21. if p is current.p1:
  22. p.lastgactual = p.gactual
  23. p.gactual = p.g
  24. p.airtime = 0
  25. onfloorlist.append(1)
  26.  
  27. elif entrex and p.y <= self.y + self.dim[1] and p.y + p.scale[1] >= int(self.dim[1]/2) + self.y:
  28. p.y = self.y + self.dim[1]
  29. onfloorlist.append(0)
  30. p.gm = p.g
  31. p.gactual = p.g
  32.  
  33. entrey = p.y + p.scale[1] >= self.y + (p.g + 1) and p.y <= self.y + self.dim[1] - (p.g + 1)
  34.  
  35. if entrey and p.x + p.scale[0] >= self.x - p.speed and p.x + p.scale[0] <= int(self.dim[0]/2) + self.x:
  36. p.x -= p.speed
  37. onfloorlist.append(0)
  38. elif entrey and p.x <= self.x + self.dim[0] and p.x + p.scale[0] >= int(self.dim[0]/2) + self.x:
  39. p.x += p.speed
  40. onfloorlist.append(0)
  41.  
  42. return onfloorlist
  43.  
  44. def loop(lst):
  45. for j in current.mobs + current.p1.invoc + [current.p1]:
  46. onfloorlist = []
  47. for i in lst:
  48. wall.affiche(i)
  49. onfloorlist = wall.colision(i, onfloorlist, j)
  50. j.onfloor = bool(onfloorlist)
  51.  
  52. class boost():
  53.  
  54. def __init__(self,x,y,dim,color,type):
  55. self.x = x
  56. self.y = y
  57. self.dim = dim
  58. self.type = type
  59. self.rect = (self.x,self.y,self.dim[0],self.dim[1])
  60. self.present = True
  61. self.color = color
  62. self.yh = self.y - 6
  63. self.xh = self.x
  64. self.dimh = (self.dim[0]-16,self.dim[1]-16)
  65. self.vh = 1
  66. self.image = pygame.transform.scale(pygame.image.load("texture\\evr\\boost\\" + self.type + ".png"),self.dimh)
  67.  
  68. def blit(self):
  69. pygame.draw.rect(fen1,self.color,((self.x,self.y+self.dim[1]-6),(self.dim[0],6)))
  70. if self.present:
  71. fen1.blit(self.image,(self.xh+8,self.yh))
  72.  
  73. def repop(self):
  74. if self.time + 20 <= time.clock():
  75. self.present = True
  76.  
  77. def animation(self):
  78. self.xh = self.x
  79. self.yh += self.vh
  80. if self.yh + self.dimh[1] >= self.y + self.dim[1] - 10 or self.yh <= self.y - 6:
  81. self.vh *= -1
  82.  
  83. def imageGet(self):
  84. if self.type == 'heal':
  85. self.image = pygame.transform.scale(pygame.image.load('texture\\evr\\boost\\heal.png'),self.dimh)
  86.  
  87. elif self.type == 'speed':
  88. self.image = pygame.transform.scale(pygame.image.load('texture\\evr\\boost\\speed.png'),self.dimh)
  89.  
  90. def action(self):
  91. if colision(current.p1.rect, self.rect):
  92. current.p1.y -= 6
  93. if self.type == 'heal' and self.present:
  94. self.present = False
  95. self.time = time.clock()
  96. player.modiflife(current.p1,500)
  97. elif self.type == 'speed' and self.present:
  98. self.present = False
  99. self.time = time.clock()
  100. current.p1.action.append(('speed',5*60))
  101. current.p1.speed += 5
  102.  
  103. def loop(lst):
  104. for i in lst:
  105. try:
  106. boost.repop(i)
  107. except:
  108. pass
  109. i.rect = (i.x,i.y,i.dim[0],i.dim[1])
  110. boost.action(i)
  111. boost.animation(i)
  112. boost.blit(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement