-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
102 lines (77 loc) · 3.25 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import pygame
import os
import random
from pacman import run_game
from board import boards, test_board, randomize_board
from generate import create_game_tree, populate_tree, print_tree
from image_captioning import predict_step
import start_screen
WIDTH = 900
HEIGHT = 950
def find_and_return_random_files(folder_path):
if not os.path.isdir(folder_path):
raise ValueError("Invalid folder path")
all_files = os.listdir(folder_path)
image_files = [file for file in all_files if file.lower().endswith(('.jpg', '.jpeg', '.png'))]
if len(image_files) < 3:
raise ValueError("There are not enough image files in the folder")
random_files = random.sample(image_files, 3)
return [os.path.join(folder_path, file) for file in random_files]
imgs = find_and_return_random_files('./images')
captions = predict_step(imgs)
root = None
if __name__ == "__main__":
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Two-Pac")
font = pygame.font.Font(None, 36)
clock = pygame.time.Clock()
loading_duration = 3000 # 3000 = 3 sec
start_time = pygame.time.get_ticks()
# Parameters for the loading icon
center = (WIDTH // 2, HEIGHT // 2)
radius = 50
angle = 0
color = (255, 255, 255)
thickness = 5
screen.fill((0, 0, 0))
# Draw the circular loading icon
# start_angle = math.radians(angle)
# end_angle = math.radians(angle + 270)
# pygame.draw.arc(screen, color, (center[0]-radius, center[1]-radius, radius*2, radius*2), start_angle, end_angle, thickness)
padding = 30
loading_text = font.render('Loading...', True, color)
text2 = font.render('Analyzing Images...', True, color)
text3 = font.render('Extracting Memories...', True, color)
text_rect = loading_text.get_rect(center=(center[0], center[1] + radius - 10))
screen.blit(loading_text, text_rect)
screen.blit(text2, text2.get_rect(center=(center[0], center[1] + radius + 20)))
screen.blit(text3, text3.get_rect(center=(center[0], center[1] + radius + 50)))
pygame.display.flip()
root = create_game_tree(imgs)
root = populate_tree(root, captions)
# loadingComplete = False
# while not loadingComplete:
# for event in pygame.event.get():
# if event.type == pygame.QUIT:
# pygame.quit()
# sys.exit()
# # Update the screen with loading information
# screen.fill((0, 0, 0))
# screen.blit(loading_text, text_rect)
# screen.blit(text2, text2.get_rect(center=(center[0], center[1] + radius + 20)))
# screen.blit(text3, text3.get_rect(center=(center[0], center[1] + radius + 50)))
# pygame.display.flip()
# # Populate the tree and check if loading is complete
# loadingComplete = populate_tree(root, captions)
# # Delay to give time for the screen update
# clock.tick(60)
# angle = (angle + 5) % 360
# if pygame.time.get_ticks() - start_time > loading_duration:
# loadingComplete = True
# clock.tick(60)
# root = create_game_tree(imgs)
# loadingComplete = populate_tree(root, captions)
# print_tree(root)
# run_game()
start_screen.main_menu(screen, root, imgs)