INvaders of Perdor (Sprites - SE REPETA PIUJ)
Thu May 19 2022 01:02:53 GMT+0000 (Coordinated Universal Time)
from niqqa import * #### CLASA PLAYER + GROUP SPRITES PT PLAYER#################33 class Player(pygame.sprite.Sprite): def __init__(self): super().__init__() self.x=playerX self.y=playerY self.image=Razboinic self.rect=Razboinic.get_rect(topleft=[playerX,playerY]) self.glont=pius self.health=100 self.patratglontstang=pius.get_rect() self.patratglontdrept=pius.get_rect() self.patratlungimeglont=self.glont.get_width() self.patratlatimeglont=self.glont.get_height() self.bullet_damage=5 self.aparitie=True def bariere(): global playerX if playerX<0: playerX=0 if playerX>1000: playerX=1000 def health_bar(): global amount_damage_taken all_health_bar=pygame.draw.rect(Control_Panel,(0,0,0),(30,30,240,40),3,border_radius=5) current_health=200 target_health=current_health-amount_damage_taken+heal if current_health>=target_health: transition_health_rect_width=current_health-target_health elif current_health<target_health: transition_health_rect_width=target_health-current_health red_bar=pygame.draw.rect(Control_Panel,(255,0,0),(32,32,target_health+36,36),0,border_radius=5) transition_bar=pygame.draw.rect(Control_Panel,(100,0,200),(target_health+36,32,transition_health_rect_width,38),0,border_radius=5) for n in range(1,5): slash=pygame.draw.line(Control_Panel,(0,0,0),(59*n+32,30),(32+59*(n-1),68),4) def APARITIE(self): if self.aparitie: group_Player.add(self) cioata_stanga_PL.aparitie=True cioata_dreapta_PL.aparitie=True group_Player.draw(WIN) elif self.aparitie==False: group_Player.remove(self) def control_panel(): global buff global amount_damage_taken WIN.blit(Control_Panel,(0,580)) pygame.draw.circle(Control_Panel,(0,0,0),(77,150),17,2) pygame.draw.circle(Control_Panel,(0,0,0),(205,150),17,2) font=pygame.font.SysFont("chalkduster.ttf",25) font_as=pygame.font.SysFont("chalkduster.ttf",23) movement_speed_text=font.render("Speeduleanu",True,"green") WIN.blit(movement_speed_text,(18,680)) attack_speed_text1=font_as.render("Mai fumeaza din ele",True,"yellow") WIN.blit(attack_speed_text1,(133,662)) attack_speed_text2=font_as.render("da le drecu",True,"yellow") WIN.blit(attack_speed_text2,(165,685)) if buff==0: pygame.draw.circle(Control_Panel,(100,0,150),(77,150),15) pygame.draw.circle(Control_Panel,(100,0,150),(205,150),15) if buff!=0: pygame.draw.circle(Control_Panel,(0,255,0),(205,150),15) pygame.draw.circle(Control_Panel,(0,255,0),(77,150),15) group_Player=pygame.sprite.Group() America=Player() ############### CLASA BULLET + CLASA CIOTARE PT PLAYER ############### class Bullet(pygame.sprite.Sprite): def __init__(self,image,q): super().__init__() self.x=random_enemy_x self.y=random_enemy_y self.image=image self.rect=self.image.get_rect() self.width=self.rect.width self.height=self.rect.height self.aparitie=q class Ciotarele(Bullet): def __init__(self,x): super().__init__(pius,False) self.stanga_sau_dreapta=x if self.stanga_sau_dreapta==1: self.rect.topleft=(playerbx-20,1000) elif self.stanga_sau_dreapta==2: self.rect.topleft=(playerbx+50,1000) else: self.rect.topleft=(-300,0) def cioateletata(self): WIN.blit(pius,(playerX,playerY)) WIN.blit(pius,(playerX+70,playerY)) def fireb(self): global statusul global playerby global bullety_change_player statusul='fire' bullety_change_player=-7 if self.stanga_sau_dreapta==1: self.rect.topleft=(playerbx-20,playerby) if self.stanga_sau_dreapta==2: self.rect.topleft=(playerbx+50,playerby) if playerby<=-65: statusul='ready' playerby=565 bullety_change_player=0 def trage(self): global playerby if statusul == "fire": self.fireb() cioata_stanga_PL=Ciotarele(1) cioata_dreapta_PL=Ciotarele(2) group_bullets_player=pygame.sprite.Group() def Ciotarele_afisaj(): global group_bullets_player global playerby playerby+=bullety_change_player if cioata_dreapta_PL.aparitie and cioata_stanga_PL.aparitie: if cioata_stanga_PL.stanga_sau_dreapta==1: group_bullets_player.add(cioata_stanga_PL) cioata_stanga_PL.trage() if cioata_dreapta_PL.stanga_sau_dreapta==2: cioata_dreapta_PL.trage() group_bullets_player.add(cioata_dreapta_PL) cioata_dreapta_PL.cioateletata() group_bullets_player.draw(WIN) ####################################################################3 ######### CLASA ENEMY + PERDOARELE #################3 class Enemy(pygame.sprite.Sprite): def __init__(self,image,x,y,q): super().__init__() self.image=pygame.image.load(image) self.x=x self.y=y self.health=100 self.bulletx=self.x self.bullety=self.y self.rect=self.image.get_rect(topleft=(self.x,self.y)) self.width=self.image.get_width() self.height=self.image.get_height() self.cioata=piuj self.cioatapatrat=piuj.get_rect() self.cioatalatime=self.cioatapatrat.height self.cioatalungime=self.cioatapatrat.width self.xglontincur=self.x+15 self.yglontincur=self.y+30 self.patratglontincur=piuj.get_rect() self.patratglontincur.topleft=(self.xglontincur,self.yglontincur) self.bullet_damage=20 self.aparitie=q self.cacare_time=False x_change=2 y_change=2 def moverestr(self): if self.x==maximx and self.y==maximy: self.x_change=-2 self.y_change=-2 if self.x==minx and self.y==miny: self.x_change=2 self.y_change=2 if self.y==maximy and self.x==minx: self.y_change=-2 self.x_change=2 if self.y==miny and self.x==maximx: self.y_change=2 self.x_change=-2 if self.x==minx and self.y!=maximy and self.y_change==-2 and self.x_change==-2: self.y_change=-2 self.x_change=2 if self.x==minx and self.y!=maximy and self.y_change==2 and self.x_change==-2: self.y_change=2 self.x_change=-2 if self.y==miny and self.x!=maximx and self.x_change==-2 and self.y_change==-2: self.y_change=2 self.x_change=-2 if self.y==miny and self.x!=maximy and self.x_change==2 and self.y_change==-2: self.y_change=2 self.x_change=2 if self.x==minx and self.y!=maximy and self.y_change==-2 and self.x_change==2: self.y_change=-2 self.x_change=2 if self.x==minx and self.y!=maximy and self.y_change==2 and self.x_change==-2: self.y_change=2 self.x_change=2 if self.y==miny and self.x!=maximx and self.x_change==-2 and self.y_change==2: self.y_change=2 self.x_change=-2 if self.y==miny and self.x!=maximy and self.x_change==2 and self.y_change==2: self.y_change=2 self.x_change=2 if self.x==maximx and self.y!=miny and self.y_change==-2: self.y_change=-2 self.x_change=-2 if self.x==maximx and self.y!=maximy and self.y_change==2: self.y_change=-2 self.x_change=-2 if self.y==maximy and self.x!=maximx and self.x_change==-2: self.y_change=-2 self.x_change=-2 if self.y==maximy and self.x!=maximx and self.x_change==2: self.y_change=-2 self.x_change=2 if self.x==maximx and self.y!=maximy and self.y_change==2 and self.x_change==2: self.x_change=-2 self.y_change=-2 if self.x==maximx and self.y!=maximy and self.y_change==-2 and self.x_change==2: self.x_change=-2 self.y_change=2 if self.x<minx: self.x=minx if self.x>maximx: self.x=maximx if self.y<miny: self.y=miny if self.y>maximy: self.y=maximy if self.y==miny: self.y_change=2 if self.y==maximy: self.y_change=-2 if self.x==maximx and (self.y!=miny or self.y==maximy or self.y==miny) and self.x_change==2: self.x_change=-2 if self.x==maximx and (self.y!=maximy or self.y!=miny) and self.x_change==-2 and self.y_change==-2: self.y_change=2 self.x_change=-2 def APARITIE(self): global Perdor if self.aparitie==False: self.cacare_time=False group_enemies.remove(self) if self.aparitie: self.cacare_time=True Perdor(self).aparitie=True group_enemies.add(self) group_enemies.draw(WIN) group_enemies=pygame.sprite.Group() Butoi=Enemy(os.path.join("shits","DADA.png"),random_enemy_x,random_enemy_y,True) class Perdor(Bullet): def __init__(self,al_cui): super().__init__(piuj,False) self.al_cui=al_cui self.x=al_cui.bulletx self.y=al_cui.bullety self.al_cui_aparitie=al_cui.aparitie self.rect=piuj.get_rect() if al_cui.aparitie: self.aparitie=True else: self.aparitie=False self.rect.topleft=(self.x,self.y) self.rect.bottomright=(self.x+self.rect.width,self.y+self.rect.height) def timer(self): global kronos global current_time global shittime if current_time-shittime<1500: kronos=10 else: kronos=0 def lansarea(self): global current_time global shittime if current_time-shittime>1500: shittime=pygame.time.get_ticks() def Aparitie_perdor(self): global group_boss_bullet if self.aparitie: group_boss_bullet.add(self) else: group_boss_bullet.remove(self) group_boss_bullet=pygame.sprite.Group() perdor_Butoi=Perdor(Butoi) def Perdor_afisaj(al_cui): global group_boss_bullet global kronos al_cui.xglontincur+=al_cui.x_change al_cui.bullety+=kronos al_cui.yglontincur+=al_cui.y_change Perdor(al_cui).timer() Perdor(al_cui).lansarea() Perdor(al_cui).Aparitie_perdor() if al_cui.bullety>=800: al_cui.bulletx=al_cui.xglontincur al_cui.bullety=al_cui.yglontincur ############### ATRIBUTES FUNCTIONS + GAME ATRIBUTES############3 def Enemy_atributes(ale_cui): global amount_damage_taken_mob ale_cui.xglontincur+=0 ale_cui.APARITIE() ale_cui.health-=amount_damage_taken_mob ale_cui.rect.topleft=(ale_cui.x,ale_cui.y) ale_cui.x+=ale_cui.x_change ale_cui.y+=ale_cui.y_change if ale_cui.health<=0: ale_cui.health=0 ale_cui.aparitie=False ale_cui.moverestr() def Bullet_Atributes(): Ciotarele_afisaj() Perdor_afisaj(Butoi) group_boss_bullet.draw(WIN) def Player_Atributes(): global playerX playerX+=move Player.bariere() America.APARITIE() America.health+=heal America.health-=amount_damage_taken America.rect.topleft=(playerX,playerY) America.patratglontstang.topleft=(playerbx-20,playerby-7) America.patratglontdrept.topleft=(playerbx+50,playerby-7) America.patratglontstang.bottomright=(playerbx-20+America.patratlungimeglont,playerby-7+America.patratlatimeglont) America.patratglontdrept.bottomright=(playerbx+50+America.patratlungimeglont,playerby-7+America.patratlatimeglont) if America.health<=0: America.health=0 America.aparitie=False ############################ FUNCTIONALITATE JOC ##################################### def eventtypes(): global move global playerbx global playerby global playerX for event in pygame.event.get(): if event.type==pygame.QUIT: global run run==False pygame.quit() sys.exit() if event.type==pygame.KEYDOWN: if event.key==pygame.K_LEFT: move=-2.5 if event.key==pygame.K_RIGHT: move=2.5 if event.key==pygame.K_UP: if statusul=='ready': playerbx=playerX+20 if cioata_stanga_PL.aparitie==True: Ciotarele.fireb(cioata_dreapta_PL) cioata_stanga_PL.fireb() if event.type==pygame.KEYUP: if event.key==pygame.K_LEFT: move=0 if event.key==pygame.K_RIGHT: move=0 def wallpaper(): WIN.blit(fundal,(0,0)) def currenting_time(): global current_time current_time=pygame.time.get_ticks() def GAME_ATRIBUTES(): currenting_time() eventtypes() wallpaper() def control_panel(): Player.health_bar() Player.control_panel() def flip_the_screen(): pygame.display.flip() while run: clock.tick(FPS) GAME_ATRIBUTES() Player_Atributes() Enemy_atributes(Butoi) Bullet_Atributes() control_panel() flip_the_screen()
Lipsteste niqqa* !
Comments