Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class power():
- def dash():
- def calcspeed(d):
- if abs(d) < 0.5:
- if d > 0:
- d = 1
- else:
- d = -1
- return (5*current.p1.g)/abs(d)
- x,y = current.p1.x+int(current.p1.scale[0]/2),current.p1.y+int(current.p1.scale[1]/2)
- x1,y1 = pygame.mouse.get_pos()
- if y1 >= current.p1.y:
- boom = True
- else:
- boom = False
- try:
- dir = (y1-y)/(x1-x)
- speed = calcspeed(dir)
- if x1 < current.p1.x+int(current.p1.scale[0]/2):
- speed *= -1
- except:
- if y1 == current.p1.y:
- if x1 < current.p1.x+int(current.p1.scale[0]/2):
- dir = 'droite'
- else:
- dir = 'gauche'
- speed = 0
- else:
- if y1 < current.p1.y+int(current.p1.scale[1]/2):
- dir = 'bas'
- else:
- dir = 'haut'
- speed = 0
- current.p1.y += current.p1.g + 2
- current.p1.action.append(('dash',dir,speed,boom))
- def dashdamage(boom):
- AOE = (current.p1.x-100+int(current.p1.scale[0]/2), current.p1.y-100+int(current.p1.scale[1]/2), 200, 200)
- multy = 20
- if boom:
- multy *= 2.2
- dmg = multy*current.p1.lastgactual
- for m in current.mobs:
- if colision(AOE, m.rect):
- m.life -= dmg
- def soulabsorber():
- x,y = current.p1.x+int(current.p1.scale[0]/2),current.p1.y+int(current.p1.scale[1]/2)
- AOE = (x-250, y-250, 500, 500)
- for m in current.mobs:
- if colision(AOE, m.rect):
- m.IA = False
- m.action.append(('no IA',5*60))
- class sheep():
- def __init__(self,x,y,dim,type):
- self.x = x
- self.y = y
- self.scale = dim
- self.img = pygame.transform.scale(pygame.image.load('texture\\mob\\sheep\\'+type+'.png').convert_alpha(),self.scale)
- if current.p1.imgdir == 'droite':
- self.dir = 1
- else:
- self.dir =-1
- self.img = pygame.transform.flip(self.img,True,False)
- self.type = type
- self.speed = 4
- self.g = 4
- self.gaccé = 1.05
- self.gm = self.g
- self.gactual = self.g
- self.onfloor = False
- self.airtime = 0
- self.touchm = []
- def move(self):
- power.sheep.calcgravity(self)
- self.x += self.dir*self.speed
- self.y += self.gactual
- self.rect = (self.x,self.y,self.scale[0],self.scale[1])
- def calcgravity(self):
- self.gactual = int(self.gm + self.gaccé*self.airtime)
- if self.onfloor:
- self.airtime = 0
- else:
- self.airtime += 1
- def contact(self):
- for m in current.mobs:
- if colision(self.rect, m.rect):
- if self.type == 'explosif':
- m.life -= 1500
- for i in range(20):
- 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))
- current.p1.invoc.remove(self)
- if self.type == 'burn' and not(m in self.touchm):
- m.action.append(('burn',5,4 * 60))
- self.touchm.append(m)
- if self.type == 'eater'and not(m in self.touchm):
- m.life -= 500
- self.touchm.append(m)
- def loop(lst):
- for mouton in lst:
- power.sheep.move(mouton)
- power.sheep.contact(mouton)
- fen1.blit(mouton.img, (mouton.x, mouton.y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement