Skip to content

Commit

Permalink
final v1
Browse files Browse the repository at this point in the history
  • Loading branch information
whyismynamerudy committed Jan 28, 2024
1 parent 2aa8a47 commit db18905
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 13 deletions.
39 changes: 39 additions & 0 deletions board.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,44 @@ def randomize_board(num):

return new_board


def return_board():
return [
[6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5],
[3, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 3],
[3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 3, 3],
[3, 3, 1, 6, 4, 4, 5, 1, 6, 4, 4, 4, 5, 1, 3, 3, 1, 6, 4, 4, 4, 5, 1, 6, 4, 4, 5, 1, 3, 3],
[3, 3, 2, 3, 0, 0, 3, 1, 3, 0, 0, 0, 3, 1, 3, 3, 1, 3, 0, 0, 0, 3, 1, 3, 0, 0, 3, 2, 3, 3],
[3, 3, 1, 7, 4, 4, 8, 1, 7, 4, 4, 4, 8, 1, 7, 8, 1, 7, 4, 4, 4, 8, 1, 7, 4, 4, 8, 1, 3, 3],
[3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3],
[3, 3, 1, 6, 4, 4, 5, 1, 6, 5, 1, 6, 4, 4, 4, 4, 4, 4, 5, 1, 6, 5, 1, 6, 4, 4, 5, 1, 3, 3],
[3, 3, 1, 7, 4, 4, 8, 10, 3, 3, 1, 7, 4, 4, 5, 6, 4, 4, 8, 1, 3, 3, 1, 7, 4, 4, 8, 1, 3, 3],
[3,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4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 3],
[7, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8]
]


if __name__=='__main__':
print(randomize_board(2))
42 changes: 29 additions & 13 deletions start_screen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pygame
from generate import print_tree
from board import boards, test_board, return_board
import sys
import pacman
# TODO: import view photo files
Expand Down Expand Up @@ -44,48 +45,61 @@ def main_menu(screen, root, imgs):
run = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_s:
wl, num_shards = pacman.run_game(root, 0, None)
test_board = return_board()
wl, num_shards = pacman.run_game(root, 0, None, board=test_board)
if wl:
print("won level")
vic_track.append(('Won', 4))
change_screen_win_screen(wl)
wl, num_shards = pacman.run_game(root.right, 0, None)
test_board = return_board()
wl, num_shards = pacman.run_game(root.right, 0, None, board=test_board)
if wl:
# won second game
vic_track.append(('Won', 4))
change_screen_win_screen(wl)
wl, num_shards = pacman.run_game(root.right.right, 0, None)
test_board = return_board()
wl, num_shards = pacman.run_game(root.right.right, 0, None, board=test_board)
else:
# lost second game
vic_track.append(('Loss', num_shards))
change_screen_win_screen(wl)
wl, num_shards = pacman.run_game(root.right.left, 0, None)
test_board = return_board()
wl, num_shards = pacman.run_game(root.right.left, 0, None, board=test_board)

else:
print("lost level")
vic_track.append(('Loss', num_shards))
change_screen_win_screen(wl)
wl, num_shards = pacman.run_game(root.left, 0, None)
test_board = return_board()
wl, num_shards = pacman.run_game(root.left, 0, None, board=test_board)
if wl:
# won second game
vic_track.append(('Won', 4))
change_screen_win_screen(wl)
wl, num_shards = pacman.run_game(root.left.right, 0, None)
test_board = return_board()
wl, num_shards = pacman.run_game(root.left.right, 0, None, board=test_board)
else:
# lost second game
vic_track.append(('Loss', num_shards))
change_screen_win_screen(wl)
wl, num_shards = pacman.run_game(root.left.left, 0, None)
test_board = return_board()
wl, num_shards = pacman.run_game(root.left.left, 0, None, board=test_board)

elif event.key == pygame.K_p:
view_photos(imgs)
view_photos(screen, imgs)
screen = pygame.display.set_mode([900, 950])
pygame.display.set_caption("Menu")
screen.blit(MENU_TEXT, MENU_RECT)
screen.blit(LOGO_TEXT, LOGO_RECT)
screen.blit(START_TEXT, START_RECT)
screen.blit(PHOTOS_TEXT, PHOTOS_RECT)
screen.blit(LOGO_PIC, LOGO_PIC.get_rect(center=(450, 780)))

pygame.display.update()
pygame.display.flip()

pygame.quit()

def view_photos(imgs):
def view_photos(screen, imgs):
# imgs = ['file.jpg', 'photo.png']
screen = pygame.display.set_mode([900, 950])
pygame.display.set_caption("Photos")
Expand All @@ -95,7 +109,6 @@ def view_photos(imgs):

screen.blit(PHOTOS_TEXT, PHOTOS_RECT)


image_width, image_height = 300, 300 # Size of each image
padding = 20 # Space between images
images_per_row = 2 # Number of images per row
Expand All @@ -119,11 +132,14 @@ def view_photos(imgs):
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_r:
run = False

pygame.display.update()
pygame.display.flip()
pygame.quit()

#return None

def change_screen_win_screen(wl):
screen = pygame.display.set_mode([900, 950])
Expand Down

0 comments on commit db18905

Please sign in to comment.