def print_text(mes, x, y, font_color=(0, 0, 0), font_size=30, font_type='data/18897.otf'): font_type = pygame.font.Font(font_type, font_size) text = font_type.render(mes, True, font_color) screen.blit(text, (x, y))
def start_screen(): fon = pygame.transform.scale(load_image('fon.png')[0], (WIDTH, HEIGHT)) screen.blit(fon, (0, 0)) text = 'DARKCASTLE' for i in range(len(text)): print_text(text[i], 10, 70 * i, (75, 12 - i, 12 - i), 70) while True: botton = Button(100, 50) botton_quit = Button(100, 50) botton.draw(50, 20, 'GAME', lvl_up, 50) botton_quit.draw(50, 71, 'EXIT', terminate, 50) pygame.event.get() pygame.display.flip()
def lvl_up(): fon = pygame.transform.scale(load_image('fon.png')[0], (WIDTH, HEIGHT)) screen.blit(fon, (0, 0)) text = 'DARKCASTLE' botton_lvl1 = Button(100, 50) botton_lvl2 = Button(100, 50) botton_quit = Button(100, 50) for i in range(len(text)): print_text(text[i], 10, 70 * i, (75, 12 - i, 12 - i), 70) while True: botton_lvl1.draw(50, 110, 'lvl_1', lvl_1, 50) botton_lvl2.draw(50, 171, 'lvl_2', lvl_2, 50) botton_quit.draw(50, 271, 'quit', terminate, 50) pygame.event.get() pygame.display.flip()
def draw_panel(self): x = display_width // 4 + 50 y = display_height - 100 side = 80 step = 100 for cell in self.inventory_panel: pygame.draw.rect(screen, (200, 215, 227), (x, y, side, side), 2) if cell is not None: screen.blit(cell.image, (x + 15, y + 15)) print_text(str(cell.amount), x + 50, y + 50, font_size=20, font_color=(143, 123, 121)) x += step
def draw_whole(self): x = 40 y = 150 side = 80 step = 100 pygame.draw.rect(screen, (182, 195, 206), (x - 20, y - 20, 420, 220), 2) for cell in self.whole_inventoty: pygame.draw.rect(screen, (200, 215, 227), (x, y, side, side), 2) if cell is not None: screen.blit(cell.image, (x + 15, y + 15)) print_text(str(cell.amount), x + 50, y + 50, font_size=20, font_color=(143, 123, 121)) x += step if x == 440: x = 40 y += step