def drawStats(screen,player): player.updateStats() #stats i=0 stats= player.getStatsDico() for stat in stats: yPOS=450+(i*30) draw_text(screen,stat, 'fonts/No_Color.ttf', 15, BLACK, 80, yPOS, False) nbBlocks=int(5*stats[stat]/STATS_MAX_COMMUN[stat]) if nbBlocks==0: nbBlocks=1 if nbBlocks>5: nbBlocks=5 #on recupère le grade de la stat color =(100,64,31) gradeStat="commun" for grade in STATS_GRADE_DATA[stat].keys(): if stats[stat] >=STATS_GRADE_DATA[stat][grade]: color = COLOR_OF_GRADE[grade] gradeStat=grade if stats[stat] <STATS_MAX_COMMUN[stat]: for j in range(nbBlocks): pygame.draw.rect(screen,color,(80+(j*55),yPOS+20,50,5)) else: for j in range(GRADES.index(gradeStat)+1): pygame.draw.rect(screen,COLOR_OF_GRADE[GRADES[j]],(80+(j*55),yPOS+20,50,5)) i+=1
def drawInventory(screen): #on dessine les background #inventaire fond pygame.draw.rect(screen,(164,131,80),(690,40,505,635)) #inventaire bords pygame.draw.rect(screen,(100,64,31),(690,40,505,635),5) #profil fond pygame.draw.rect(screen,(164,131,80),(50,40,505,635)) #profil bords pygame.draw.rect(screen,(100,64,31),(50,40,505,635),5) #puis les texts draw_text(screen,'Inventaire', 'fonts/No_Color.ttf', 30, BLACK, 950, 80, True) draw_text(screen,'Profil', 'fonts/No_Color.ttf', 30, BLACK, 300, 80, True)
def drawShop(screen, player, merchant): # on dessine les background # fond inventaire player pygame.draw.rect(screen, (164, 131, 80), (50, 40, 505, 635)) # bords inventaire player pygame.draw.rect(screen, (100, 64, 31), (50, 40, 505, 635), 5) # fond inventaire marchand pygame.draw.rect(screen, (164, 131, 80), (SCREEN_WIDTH - 50 - 505, 40, 505, 635)) # bords inventaire marchand pygame.draw.rect(screen, (100, 64, 31), (SCREEN_WIDTH - 50 - 505, 40, 505, 635), 5) # bord bouton retour # puis les texts draw_text(screen, 'Inventaire du marchand', 'fonts/No_Color.ttf', 30, BLACK, (SCREEN_WIDTH - 50 - 505) + 505 // 2, 80, True) draw_text(screen, 'Votre inventaire', 'fonts/No_Color.ttf', 30, BLACK, 302, 80, True) draw_text(screen, to_gold(player.money), "fonts/SuperLegendBoy-4w8Y.ttf", 20, BLACK, 302, 120, True) draw_text(screen, to_gold(merchant.money), "fonts/SuperLegendBoy-4w8Y.ttf", 20, BLACK, (SCREEN_WIDTH - 50 - 505) + 505 // 2, 120, True)
def drawCraftOverlay(screen,page,inventaire): global listeCraftSprite, slots #on dessine les background largeur =505 hauteur = 100 spaceBetween = 15 crafts, listeCraftSprite = craftsOfPage(page) slots=[] for i in range(len(listeCraftSprite)): x = 700 y = (i*hauteur+i*spaceBetween) item = listeCraftSprite[i] craft = crafts[i]["craft"] colorGrade = COLOR_OF_GRADE[item.grade] ###FOND #inventaire fond s = pygame.Rect(690,40+y,largeur,hauteur) pygame.draw.rect(screen,(164,131,80),s) #inventaire bords pygame.draw.rect(screen,(100,64,31),s,5) ##APPERCU img = pygame.transform.scale(item.image,(64,64)) #on la resize rect = img.get_rect() #on la place en haut à gauche du cadre pos= (700, 60+y) rect = rect.move(pos) #item.move(pos) screen.blit(img, rect) #NOM if len(item.name) > 20: txt=item.shortName else: txt=item.name draw_text(screen,txt, 'fonts/No_Color.ttf', 20, BLACK, 780,60+y, False) #grade draw_text(screen,item.grade, 'fonts/No_Color.ttf', 15, colorGrade, 780,90+y, False) #ingrédients dispo dispo,needed = nbIngDispo(craft,inventaire) draw_text(screen,str(dispo)+" / "+str(needed), 'fonts/No_Color.ttf', 30, BLACK, 1050,70+y, False) slots.append([s,crafts[i]])
def stage_display(self, tiles, font, canvas, counters, pygame, settings, mirror_h=False, mirror_v=False, palette=None): canvas.blit(self.img_bg, (0, 0)) text = 'BY CEREAL KILLER' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 48, text, font, 6, pygame, canvas, settings) text = '2020' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 56, text, font, 6, pygame, canvas, settings) # tools.draw_tile(canvas, pygame, settings, 152, 72, tiles['gem'], 0, 0, # settings.system['palettes'][1]) # tools.draw_tile(canvas, pygame, settings, 152, 84, tiles['coin'], 0, 0, # settings.system['palettes'][2]) if self.page == 9: self.page = 0 elif self.page == -1: self.page = 8 if self.page != 0: canvas.fill((120, 0, 0), (0, 72, self.space_width, 128)) if self.page == 0: text = 'ARROW KEYS FOR HELP' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 180, text, font, 6, pygame, canvas, settings) elif self.page == 1: text = 'STORY:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 76, text, font, 4, pygame, canvas, settings) text = 'YOU ARE A HERALD.' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 88, text, font, 6, pygame, canvas, settings) text = 'YOUR AIM IS TO SAFELY TRAVERSE' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 96, text, font, 6, pygame, canvas, settings) text = 'THROUGH THE GOBLINS VALLEY' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 104, text, font, 6, pygame, canvas, settings) text = 'OR MAKE IT AS FAR AS POSSIBLE.' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 112, text, font, 6, pygame, canvas, settings) text = 'KEYBOARD CONTROLS:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 128, text, font, 4, pygame, canvas, settings) text = 'RUN FORWARD: UP, W' tools.draw_text(40, 140, text, font, 6, pygame, canvas, settings) text = 'RUN BACKWARD: DOWN, S' tools.draw_text(40, 148, text, font, 6, pygame, canvas, settings) text = 'RUN LEFT: LEFT, A' tools.draw_text(40, 156, text, font, 6, pygame, canvas, settings) text = 'RUN RIGHT: RIGHT, D' tools.draw_text(40, 164, text, font, 6, pygame, canvas, settings) text = 'SWING SWORD: X, J' tools.draw_text(40, 180, text, font, 6, pygame, canvas, settings) text = 'SHOOT BOW: Z, K' tools.draw_text(40, 188, text, font, 6, pygame, canvas, settings) pass elif self.page == 2: text = 'HAZARDS AND HOSTILES:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 76, text, font, 6, pygame, canvas, settings) text = '-GOBLIN-' tools.draw_text(56, 88, text, font, 4, pygame, canvas, settings) text = 'PATROLS SURROUNDINGS,' tools.draw_text(56, 96, text, font, 6, pygame, canvas, settings) text = 'SHOOTS ARROWS ON SIGHT.' tools.draw_text(56, 104, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 92, tiles['goblin_s'], 0, 0, settings.system['palettes'][10]) text = '-PROJECTILE-' tools.draw_text(56, 116, text, font, 4, pygame, canvas, settings) text = 'GOBLINS ARROW,' tools.draw_text(56, 124, text, font, 6, pygame, canvas, settings) text = 'LOSE 1 HEART ON HIT.' tools.draw_text(56, 132, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 120, tiles['proj_nw'], 0, 0, settings.system['palettes'][2]) text = '-PIT-' tools.draw_text(56, 144, text, font, 4, pygame, canvas, settings) text = 'BOTTOMLESS TRAP,' tools.draw_text(56, 152, text, font, 6, pygame, canvas, settings) text = 'VERY DANGEROUS!AVOID!' tools.draw_text(56, 160, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 148, tiles['pit'], 0, 0, settings.system['palettes'][2]) text = '-FIRE-' tools.draw_text(56, 172, text, font, 4, pygame, canvas, settings) text = 'HOT FLAME, BE CAREFUL!' tools.draw_text(56, 180, text, font, 6, pygame, canvas, settings) text = 'LOSE 1 HEART ON HIT.' tools.draw_text(56, 188, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 176, tiles['fire'], 0, 0, settings.system['palettes'][3]) elif self.page == 3: text = 'EQUIPMENT AND LIFE:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 76, text, font, 6, pygame, canvas, settings) text = '-ARROW-' tools.draw_text(56, 88, text, font, 4, pygame, canvas, settings) text = 'AMMO FOR YOUR BOW,' tools.draw_text(56, 96, text, font, 6, pygame, canvas, settings) text = 'MAX 5 ARROWS.' tools.draw_text(56, 104, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 92, tiles['arrow'], 0, 0, settings.system['palettes'][2]) text = '-KEY-' tools.draw_text(56, 116, text, font, 4, pygame, canvas, settings) text = 'OPEN LOCKED CHESTS' tools.draw_text(56, 124, text, font, 6, pygame, canvas, settings) text = 'AND DOORS,MAX 5 KEYS.' tools.draw_text(56, 132, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 120, tiles['key'], 0, 0, settings.system['palettes'][4]) text = '-LOCK-' tools.draw_text(56, 144, text, font, 4, pygame, canvas, settings) text = 'REQUIRES KEY TO REMOVE,' tools.draw_text(56, 152, text, font, 6, pygame, canvas, settings) text = 'FOUND ON DOORS, CHESTS' tools.draw_text(56, 160, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 148, tiles['lock'], 0, 0, settings.system['palettes'][7]) text = '-HEART-' tools.draw_text(56, 172, text, font, 4, pygame, canvas, settings) text = 'WHEN YOU LOSE ALL' tools.draw_text(56, 180, text, font, 6, pygame, canvas, settings) text = 'IT IS GAME OVER.' tools.draw_text(56, 188, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 176, tiles['heart'], 0, 0, settings.system['palettes'][5]) elif self.page == 4: text = 'FOOD AND POTIONS:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 76, text, font, 6, pygame, canvas, settings) text = '-FRUIT-' tools.draw_text(56, 88, text, font, 4, pygame, canvas, settings) text = 'RESTORE 1 HEART' tools.draw_text(56, 96, text, font, 6, pygame, canvas, settings) text = 'OR 50 BONUS PTS.' tools.draw_text(56, 104, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 92, tiles['apple'], 0, 0, settings.system['palettes'][8]) text = '-CHICKEN-' tools.draw_text(56, 116, text, font, 4, pygame, canvas, settings) text = 'RESTORE 2 HEARTS,' tools.draw_text(56, 124, text, font, 6, pygame, canvas, settings) text = 'OR 100 BONUS PTS.' tools.draw_text(56, 132, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 120, tiles['chick'], 0, 0, settings.system['palettes'][2]) text = '-MEAT-' tools.draw_text(56, 144, text, font, 4, pygame, canvas, settings) text = 'RESTORE FULL HEARTS,' tools.draw_text(56, 152, text, font, 6, pygame, canvas, settings) text = 'OR 500 BONUS PTS.' tools.draw_text(56, 160, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 148, tiles['meat'], 0, 0, settings.system['palettes'][5]) text = '-POTION-' tools.draw_text(56, 172, text, font, 4, pygame, canvas, settings) text = 'CREATE UNKNOWN' tools.draw_text(56, 180, text, font, 6, pygame, canvas, settings) text = 'MAGICAL EFFECT.' tools.draw_text(56, 188, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 176, tiles['potion'], 0, 0, settings.system['palettes'][7]) elif self.page == 5: text = 'BONUS ITEMS:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 76, text, font, 6, pygame, canvas, settings) text = '-COIN-' tools.draw_text(56, 88, text, font, 4, pygame, canvas, settings) text = 'GIVES 100 BONUS PTS.' tools.draw_text(56, 96, text, font, 6, pygame, canvas, settings) text = ' ' tools.draw_text(56, 104, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 92, tiles['coin'], 0, 0, settings.system['palettes'][2]) text = '-GEM-' tools.draw_text(56, 116, text, font, 4, pygame, canvas, settings) text = 'GIVES 1000 BONUS PTS.' tools.draw_text(56, 124, text, font, 6, pygame, canvas, settings) text = ' ' tools.draw_text(56, 132, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 120, tiles['gem'], 0, 0, settings.system['palettes'][1]) text = '-SKULL-' tools.draw_text(56, 144, text, font, 4, pygame, canvas, settings) text = 'REVEAL LOOT ITEM' tools.draw_text(56, 152, text, font, 6, pygame, canvas, settings) text = 'IF SLICED WITH SWORD.' tools.draw_text(56, 160, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 148, tiles['skull1'], 0, 0, settings.system['palettes'][7]) elif self.page == 6: text = 'SUPER HERALD:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 76, text, font, 6, pygame, canvas, settings) text = '-DO NOT STOP-' tools.draw_text(56, 88, text, font, 4, pygame, canvas, settings) text = 'KEEP RUNNING TO GAIN' tools.draw_text(56, 96, text, font, 6, pygame, canvas, settings) text = '*2 SCORE MULTIPLIER' tools.draw_text(56, 104, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 92, tiles['hero_s'], 0, 0, settings.system['palettes'][4]) text = '-BEING SUPERB-' tools.draw_text(56, 116, text, font, 4, pygame, canvas, settings) text = 'BE SAFE AND SCORING' tools.draw_text(56, 124, text, font, 6, pygame, canvas, settings) text = 'TO STAY SUPER HERALD.' tools.draw_text(56, 132, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 120, tiles['coin'], 0, 0, settings.system['palettes'][2]) elif self.page == 7: text = 'USEFUL OBJECTS:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 76, text, font, 6, pygame, canvas, settings) text = '-TREE-' tools.draw_text(56, 88, text, font, 4, pygame, canvas, settings) text = 'CHOP IT TO GET TIMBER' tools.draw_text(56, 96, text, font, 6, pygame, canvas, settings) text = 'OR TO MAKE THROUGH.' tools.draw_text(56, 104, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 92, tiles['tree'], 0, 0, settings.system['palettes'][1]) text = '-LOG-' tools.draw_text(56, 116, text, font, 4, pygame, canvas, settings) text = 'SOMETIMES TURNS' tools.draw_text(56, 124, text, font, 6, pygame, canvas, settings) text = 'INTO ARROW WHEN CUT.' tools.draw_text(56, 132, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 120, tiles['log'], 0, 0, settings.system['palettes'][2]) text = '-GRASS-' tools.draw_text(56, 144, text, font, 4, pygame, canvas, settings) text = 'SOMETIMES TURNS' tools.draw_text(56, 152, text, font, 6, pygame, canvas, settings) text = 'INTO FRUIT WHEN CUT.' tools.draw_text(56, 160, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 148, tiles['grass'], 0, 0, settings.system['palettes'][1]) text = '-ROCK-' tools.draw_text(56, 172, text, font, 4, pygame, canvas, settings) text = 'STRONG BUT NOT' tools.draw_text(56, 180, text, font, 6, pygame, canvas, settings) text = 'UNBREAKABLE.' tools.draw_text(56, 188, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 32, 176, tiles['rock'], 0, 0, settings.system['palettes'][7]) if self.page == 8: text = 'TOP AGENTS:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 84, text, font, 6, pygame, canvas, settings) for i in range(0, min(len(self.hiscores.hiscores), 8)): if i == 2: palette = 2 elif i == 1: palette = 1 elif i == 0: palette = 4 else: palette = 6 text = str(i + 1) + ' ' + str( self.hiscores.hiscores[i] [0]) + ' ' + self.hiscores.hiscores[i][1] tools.draw_text(72, 96 + i * 12, text, font, palette, pygame, canvas, settings) text = 'HOW TO PLAY:LEFT OR RIGHT' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, self.space_height - 24, text, font, 6, pygame, canvas, settings) text = 'START: ENTER,QUIT:ESCAPE' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, self.space_height - 16, text, font, 6, pygame, canvas, settings)
def stage_display(self, tiles, font, canvas, counters, pygame, settings, mirror_h=False, mirror_v=False, palette=None): canvas.fill((150, 0, 0)) text = 'GAME OVER' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 36, text, font, 6, pygame, canvas, settings) text = 'YOUR SCORE:' + str(self.player.score) + ' PTS' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 52, text, font, 6, pygame, canvas, settings) text = 'TRAVELLED DISTANCE:' + str(self.player.dist) + ' M' tools.draw_text(24, 64, text, font, 6, pygame, canvas, settings) text = '*' + str(self.player.gems) tools.draw_text(168, 76, text, font, 6, pygame, canvas, settings) text = '*' + str(self.player.coins) tools.draw_text(168, 88, text, font, 6, pygame, canvas, settings) tools.draw_tile(canvas, pygame, settings, 152, 72, tiles['gem'], 0, 0, settings.system['palettes'][1]) tools.draw_tile(canvas, pygame, settings, 152, 84, tiles['coin'], 0, 0, settings.system['palettes'][2]) text = 'TOP AGENTS:' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, 104, text, font, 6, pygame, canvas, settings) for i in range(0, min(len(self.hiscores.hiscores), 6)): if i == 2: palette = 2 elif i == 1: palette = 1 elif i == 0: palette = 4 else: palette = 6 if i == self.score_place: if counters[0] == 0: text = str(i + 1) + ':' + str(self.hiscores.hiscores[i][0]) if self.hiscores.hiscores[i][1] == '': text += ' -INPUT NAME-' else: text += (' ' + self.hiscores.hiscores[i][1]) tools.draw_text(72, 116 + i * 12, text, font, palette, pygame, canvas, settings) else: text = str(i + 1) + ' ' + str( self.hiscores.hiscores[i] [0]) + ' ' + self.hiscores.hiscores[i][1] tools.draw_text(72, 116 + i * 12, text, font, palette, pygame, canvas, settings) text = 'RESTART: ENTER, QUIT: ESC' tools.draw_text(self.space_width // 2 - len(text) * 8 // 2, self.space_height - 16, text, font, 6, pygame, canvas, settings)
# 랭킹 정보 인스턴스 : ranking은 파일의 이름 ranking_processor = RankingProcessor("ranking") # 이상 준비 끝 # ################################################################### # 이하 카운트다운 렌더링 시작 # 기준 시각으로부터 경과한 시간을 기준으로 3초동안 렌더링을 반복한다 ready_time = time.time() while time.time() - ready_time < 3: # 화면에 표시될 정수형의 초(이 경우 0, 1, 2) gap = int(time.time() - ready_time) # 화면을 검게 칠한다음 screen.fill(c.color['BLACK']) # 그 위에 3초동안의 카운트다운을 렌더링 draw_text(screen, "Get Ready!", 80, (330, 250), c.color['RED']) draw_text(screen, "{}".format(3 - gap), 50, (495, 400), c.color['WHITE']) pg.display.update() # 새로운 기준 시각으로부터 경과한 시간을 기준으로 1초동안 렌더링을 반복한다 ready_time = time.time() while time.time() - ready_time < 1: screen.fill(c.color['BLACK']) draw_text(screen, "Dodge!", 80, (390, 320), c.color['RED']) pg.display.update() # 이상 게임 시작 전 카운트다운 # ################################################################### # 이하 게임 제어 플래그
def craftScreen(screen,fpsClock,player): global ITEMS_RECIPES #les crafts/recette ITEMS_RECIPES=[] for i in range(0,len(RECIPES) ): if RECIPES[i]["slot"]=="food": item = createRandomItem(typeItem="food",categorie="food",itemname=RECIPES[i]["img"]) else: item =createRandomItem(typeItem=RECIPES[i]["slot"],gradeItem=RECIPES[i]["grade"]) ITEMS_RECIPES.append( {"item":item , "id":i, "craft":RECIPES[i]["craft"]}) #boutons craftButton =Bouton(300 ,650, 'Craft', (164,131,80)) nextB = Bouton(1050 ,650, 'Suivant', (164,131,80),width=100, height=50,font_size=15) previousB = Bouton(850 ,650, 'Précédent', (164,131,80),width=100, height=50,font_size=15) craftScreenOn=True page =1 actif=-1 # -------- Main Program Loop ----------- while craftScreenOn: #fermeture de la fenetre for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == controls.C_CRAFT or event.key == pygame.K_ESCAPE: craftScreenOn=False if event.type == MOUSEBUTTONDOWN: if event.button == 1: if craftButton.hoover(mx,my): craft(ITEMS_RECIPES[actif],player.inventaire) if nextB.hoover(mx,my): if page == ceil(len(RECIPES)/5): pass else: page+=1 if previousB.hoover(mx,my): if page == 1: pass else: page-=1 # Detection du clic gauche la souris et de sa position activeMouse = pygame.mouse.get_pressed() mx, my = pygame.mouse.get_pos() #si on clique if activeMouse[0] == True: #on regarde pour chaque bouton for s in slots: #si on est dessus if s[0].collidepoint(mx,my): actif = s[1]["id"] #on met l'ecran en blanc screen.fill((255,255,255)) #on dessine la liste des crafts de la page drawCraftOverlay(screen,page,player.inventaire) #resultat du craft actif if actif >=0: drawResultOverlay(screen,ITEMS_RECIPES[actif],player.inventaire) #affiche les boutons craftButton.draw(screen, mx, my) nextB.draw(screen,mx,my) draw_text(screen,str(page), 'fonts/No_Color.ttf', 40, BLACK, 950,650, True) previousB.draw(screen,mx,my) pygame.display.update() fpsClock.tick(60)
def drawResultOverlay(screen,actif,inventaire): #profil fond pygame.draw.rect(screen,(164,131,80),(50,40,505,560)) #profil bords pygame.draw.rect(screen,(100,64,31),(50,40,505,560),5) item = actif["item"] colorGrade = COLOR_OF_GRADE[item.grade] craft = actif["craft"] ##APPERCU img = pygame.transform.scale(item.image,(64,64)) #on la resize rect = img.get_rect() #on la place en haut à gauche du cadre pos= (100, 60) rect = rect.move(pos) screen.blit(img, rect) #NOM if len(item.name) > 20: txt=item.shortName else: txt=item.name draw_text(screen,txt, 'fonts/No_Color.ttf', 30, BLACK, 350,80, True) #grade draw_text(screen,item.grade, 'fonts/No_Color.ttf', 20, colorGrade, 350,110, True) i=0 for stat in item.stats.keys(): txt=stat+" : "+str(item.stats[stat]) color=BLACK if item.slotequipable in inventaire.equipement.keys(): if inventaire.equipement[item.slotequipable]!=False and inventaire.equipement[item.slotequipable].stats[stat] < item.stats[stat]: color = GREEN elif inventaire.equipement[item.slotequipable]!=False and inventaire.equipement[item.slotequipable].stats[stat] > item.stats[stat]: color = RED draw_text(screen,txt, 'fonts/No_Color.ttf', 15, color, 100, 150+(i*15), False) i+=1 #la description lenLigne=45 nblignes=int(len(item.description)/(lenLigne+1)) startletter=0 for j in range(nblignes+2): if j <nblignes: if item.description[startletter+lenLigne]!=" ": draw_text(screen,item.description[startletter:startletter+lenLigne]+"-", 'fonts/No_Color.ttf', 15, BLACK, 100, 180+(i+2*15)+(j*15), False) else: draw_text(screen,item.description[startletter:startletter+lenLigne], 'fonts/No_Color.ttf', 15, BLACK, 100, 180+(i+2*15)+(j*15), False) else: draw_text(screen,item.description[startletter:startletter+lenLigne], 'fonts/No_Color.ttf', 15, BLACK, 100, 180+(i+2*15)+(j*15), False) startletter+=lenLigne #ingrédients dispo i=0 for ingredient in craft: name = ingredient quantity = craft[ingredient] #visuel if ingredient in dicNameImg["misc"]: cat = "misc/" name = NOMSDIVERS[ingredient][0] else: cat = "plants/" name = NOMSPLANTES[ingredient][0] img = pygame.image.load("./img/"+cat+ingredient+".png") img = pygame.transform.scale(img,(32,32)) rect = img.get_rect() #on la place pos= (100, 300+i*40) rect = rect.move(pos) screen.blit(img, rect) #text draw_text(screen,name+" "+str(nbIngredientInInv(name,inventaire))+"/"+str(quantity) , 'fonts/No_Color.ttf', 15, BLACK, 140,310+i*40, False) i+=1