def main(screen, clock): bg = util.get_image('background') map_button = util.get_image('maps_button') map_button = pygame.transform.scale(map_button, (350, 150)) cards_button = util.get_image('cards_button') cards_button = pygame.transform.scale(cards_button, (350, 150)) items_button = util.get_image('items_button') items_button = pygame.transform.scale(items_button, (350, 150)) screen.blit(bg, (0, 0)) screen.blit(map_button, (20, 100)) screen.blit(cards_button, (450, 100)) screen.blit(items_button, (900, 100)) while True: mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() # x w x, y h y if 20 + 350 > mouse[0] > 20 and 100 + 150 > mouse[1] > 100: if click[0] == 1: return True, 0 elif 450 + 350 > mouse[0] > 450 and 100 + 150 > mouse[1] > 100: if click[0] == 1: return True, 1 elif 900 + 350 > mouse[0] > 900 and 100 + 150 > mouse[1] > 100: if click[0] == 1: return True, 2 if not util.tick(clock): return False, -1
def main(screen, clock): bg = util.get_image('background') bg_h = 934 logo = util.get_image('logo') start = util.get_image('start_button') start = pygame.transform.scale(start, (350, 150)) option = util.get_image('options_button') option = pygame.transform.scale(option, (400, 150)) bg_animation_ticks = 200 bg_ease = util.EaseOutSine(bg_animation_ticks, util.HEIGHT - bg_h, 0) logo_ease = util.EaseOutSine(bg_animation_ticks, -50, -160) for i in range(bg_animation_ticks): # Initialize & scroll start screen screen.fill([0, 255, 0]) screen.blit(bg, (0, next(bg_ease))) screen.blit(logo, (0, next(logo_ease))) if not util.tick(clock): return False for i in range(0, 200): start.set_alpha(i/20) # doesn't make the image fully opaque option.set_alpha(i/20) screen.blit(start, (450, 350)) screen.blit(option, (420, 500)) if not util.tick(clock): return False while True: mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() x = 450 y = 350 w = 350 h = 150 if x+w > mouse[0] > x and y+h > mouse[1] > y: if click[0] == 1: return True if not util.tick(clock): return False
def main(screen, clock): bg = util.get_image('item_selection_background') bg = pygame.transform.scale(bg, (1280, 720)) return_button = util.get_image('return_button') return_button = pygame.transform.scale(return_button, (175, 60)) screen.blit(bg, (0, 0)) screen.blit(return_button, (1080, 640)) card_back = util.get_image('card_back', scale=(450, 458)) card_border = util.get_image('card_border', scale=(450, 458)) potion_image = util.get_image('Cards/potion', scale=(300, 300)) dragon_image = util.get_image('Cards/dragon', scale=(280, 280)) phoenix_image = util.get_image('Cards/phoenix', scale=(340, 340)) # blitting the selction items screen.blit(card_back, (-10, 20)) screen.blit(card_back, (410, 20)) screen.blit(card_back, (830, 20)) screen.blit(potion_image, (70, 90)) screen.blit(dragon_image, (511, 86)) screen.blit(phoenix_image, (875, 35)) screen.blit(card_border, (-10, 20)) screen.blit(card_border, (410, 20)) screen.blit(card_border, (830, 20)) # blitting the items selected card_back = pygame.transform.scale(card_back, (180, 188)) card_border = pygame.transform.scale(card_border, (180, 188)) potion_image = pygame.transform.scale(potion_image, (135, 135)) dragon_image = pygame.transform.scale(dragon_image, (112, 115)) screen.blit(card_back, (45, 510)) screen.blit(card_back, (245, 510)) screen.blit(potion_image, (75, 540)) screen.blit(dragon_image, (287, 536)) screen.blit(card_border, (45, 510)) screen.blit(card_border, (245, 510)) while True: mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() # x w x, y h y if 1080 + 175 > mouse[0] > 1080 and 640 + 60 > mouse[1] > 640: if click[0] == 1: return True, 0 if not util.tick(clock): return False
def main(screen, clock, counting_text): lose_screen = util.get_image('lose_screen') lose_screen = pygame.transform.scale(lose_screen, (680, 680)) screen.blit(lose_screen, (300, 20)) screen.blit(counting_text, (600, 330)) font = pygame.font.SysFont(None, 64, italic=True) item_text = font.render("2", 1, (43, 3, 9)) screen.blit(item_text, (600, 375)) return_button = util.get_image('return_button') return_button = pygame.transform.scale(return_button, (175, 60)) screen.blit(return_button, (710, 560)) while True: mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() # x w x, y h y if 710 + 175 > mouse[0] > 710 and 560 + 60 > mouse[1] > 560: if click[0] == 1: return True, 0 if not util.tick(clock): return False
def main(screen, clock): bg = util.get_image('map_selection_background') bg = pygame.transform.scale(bg, (1280, 720)) select_button_left = util.get_image('select_button_left') select_button_left = pygame.transform.scale(select_button_left, (150, 150)) select_button_right = util.get_image('select_button_right') select_button_right = pygame.transform.scale(select_button_right, (150, 150)) play_button = util.get_image('play_button') play_button = pygame.transform.scale(play_button, (350, 150)) return_button = util.get_image('return_button') return_button = pygame.transform.scale(return_button, (175, 60)) plain_forest = util.get_image('plain_forest') plain_forest = pygame.transform.scale(plain_forest, (866, 350)) mountain_background = util.get_image('mountain_background') mountain_background = pygame.transform.scale(mountain_background, (866, 350)) screen.blit(bg, (0, 0)) screen.blit(select_button_left, (50, 280)) screen.blit(select_button_right, (1100, 280)) screen.blit(play_button, (460, 550)) screen.blit(return_button, (1080, 640)) screen.blit(plain_forest, (222, 165)) while True: mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() if 1100 + 150 > mouse[0] > 1100 and 280 + 150 > mouse[1] > 280: if click[0] == 1: screen.blit(mountain_background, (222, 165)) if 460 + 350 > mouse[0] > 460 and 550 + 150 > mouse[1] > 550: if click[0] == 1: return True, 0 if 1080 + 175 > mouse[0] > 1080 and 640 + 60 > mouse[1] > 640: if click[0] == 1: return True, 1 if not util.tick(clock): return False, -1
def main(screen, clock): bg = util.get_image('card_selection_background') bg = pygame.transform.scale(bg, (1280, 720)) return_button = util.get_image('return_button') return_button = pygame.transform.scale(return_button, (175, 60)) screen.blit(bg, (0, 0)) screen.blit(return_button, (1080, 640)) card_back = util.get_image('card_back', scale=(200, 208)) card_border = util.get_image('card_border', scale=(200, 208)) knight_image = util.get_image('Cards/knight', scale=(100, 100)) lance_image = util.get_image('Cards/lance', scale=(100, 100)) archer_image = util.get_image('Cards/archer', scale=(100, 100)) wizard_image = util.get_image('Cards/wizard', scale=(100, 100)) # bltting card selection list screen.blit(card_back, (145, 150)) screen.blit(card_back, (395, 150)) screen.blit(card_back, (645, 150)) screen.blit(card_back, (895, 150)) screen.blit(knight_image, (190, 185)) screen.blit(archer_image, (455, 180)) screen.blit(lance_image, (710, 180)) screen.blit(wizard_image, (960, 180)) screen.blit(card_border, (145, 150)) screen.blit(card_border, (395, 150)) screen.blit(card_border, (645, 150)) screen.blit(card_border, (895, 150)) # blitting card selection card_back = pygame.transform.scale(card_back, (90, 98)) card_border = pygame.transform.scale(card_border, (90, 98)) knight_image = pygame.transform.scale(knight_image, (45, 49)) archer_image = pygame.transform.scale(archer_image, (45, 49)) lance_image = pygame.transform.scale(lance_image, (45, 49)) wizard_image = pygame.transform.scale(wizard_image, (45, 49)) screen.blit(card_back, (120, 560)) screen.blit(card_back, (220, 560)) screen.blit(card_back, (320, 560)) screen.blit(card_back, (420, 560)) screen.blit(knight_image, (149, 590)) screen.blit(archer_image, (251, 585)) screen.blit(lance_image, (353, 585)) screen.blit(wizard_image, (451, 585)) screen.blit(card_border, (120, 560)) screen.blit(card_border, (220, 560)) screen.blit(card_border, (320, 560)) screen.blit(card_border, (420, 560)) while True: mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() # x w x, y h y if 1080 + 175 > mouse[0] > 1080 and 640 + 60 > mouse[1] > 640: if click[0] == 1: return True, 0 if not util.tick(clock): return False
def init(): # Backgrounds global ground ground = util.get_image('game_ground') global card_inventory card_inventory = util.get_image('card_inventory') global game_background game_background = util.get_image('game_background') # Cards card_back = util.get_image('card_back', scale=(100, 108)) card_border = util.get_image('card_border', scale=(100, 108)) potion_image = util.get_image('Cards/potion', scale=(70, 70)) dragon_image = util.get_image('Cards/dragon', scale=(70, 70)) phoenix_image = util.get_image('Cards/phoenix', scale=(70, 70)) knight_image = util.get_image('Cards/knight', scale=(70, 70)) lance_image = util.get_image('Cards/lance', scale=(70, 70)) archer_image = util.get_image('Cards/archer', scale=(70, 70)) wizard_image = util.get_image('Cards/wizard', scale=(70, 70)) # Character for i, j in (('knight', .06), ('lance', .08), ('archer', .06), ('gunslinger', None), ('wizard', .16)): if j is None: idle_animations.append(None) continue idle_animations.append([ util.get_image(f'Characters/{i}/idle_{k+1}', scale=j) for k in range(4) ]) for i, j in (('knight', .06), ('lance', .08), ('archer', .06), ('gunslinger', None), ('wizard', .16)): if j is None: attack_animations.append(None) continue attack_animations.append([ util.get_image(f'Characters/{i}' f'/attack_{k+1}', scale=j) for k in range(4) ]) for i, j in (('porc', .07), ('wraith', .07), ('fly', .07)): if i == 'wraith': enemy_idle_images.append([ util.get_image(f'Characters/{i}/idle_{k+1}', scale=j) for k in range(9) ]) continue if i == 'fly': enemy_idle_images.append([ util.get_image(f'Characters/{i}/idle_{k+1}', scale=j) for k in range(7) ]) continue enemy_idle_images.append( util.get_image(f'Characters/{i}/idle', scale=j)) for i, j in (('porc', .07), ('wraith', .07), ('fly', .07)): if j is None: enemy_attack_animations.append(None) continue if i == 'fly': enemy_attack_animations.append([ util.get_image(f'Characters/{i}' f'/attack_{k+1}', scale=j) for k in range(4) ]) continue enemy_attack_animations.append([ util.get_image(f'Characters/{i}' f'/attack_{k+1}', scale=j) for k in range(8) ]) global faint_animations global enemy_faint_animations faint_animations = [ util.get_image(f'Faint/character/{i+1}', scale=.10) for i in range(26) ] enemy_faint_animations = [ util.get_image(f'Faint/enemy/{i+1}', scale=.10) for i in range(16) ] # Draw grid into surface global grid_hor grid_hor = pygame.Surface((1280, 410)) global grid_ver grid_ver = pygame.Surface((1280, 410)) for i in range(11): pygame.draw.line(grid_ver, GRID_COLOR, (i * GRID_SPACE_HOR + GRID_SPACE_HOR + 10, 10), (i * GRID_SPACE_HOR + 10, 400), width=10) for i in range(4): pygame.draw.line(grid_hor, GRID_COLOR, (0, GRID_SPACE_VER * (i + 1)), (1280, GRID_SPACE_VER * (i + 1)), width=10) grid_hor.set_alpha(100) grid_ver.set_alpha(100) # Draw cards into their own surfaces, global cards cards = [pygame.Surface((90, 90)) for _ in range(8)] for i in cards: i.blit(card_back, (-8, -8)) cards[0].blit(potion_image, (10, 8)) cards[1].blit(dragon_image, (10, 8)) cards[2].blit(phoenix_image, (10, 8)) cards[3].blit(knight_image, (10, 8)) cards[4].blit(lance_image, (10, 8)) cards[5].blit(archer_image, (10, 8)) # cards[6].blit(gunslinger_image, (10, 8)) cards[7].blit(wizard_image, (10, 8)) for i in cards: i.blit(card_border, (-8, -8))