import pygame
import sprites
import setup
import functions

pygame.init()

SCREEN_WIDTH = 1800
SCREEN_HEIGHT = 1000

screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
clock = pygame.time.Clock()

player = pygame.sprite.GroupSingle()
player.add(sprites.Player())

streets_scene_1 = pygame.sprite.Group()
streets_list_scene_1 = setup.setup_streets_scene_1()

streets_scene_2 = pygame.sprite.Group()
streets_list_scene_2 = setup.setup_streets_scene_2()

streets_scene_3 = pygame.sprite.Group()
streets_list_scene_3 = setup.setup_streets_scene_3()

streets_scene_4 = pygame.sprite.Group()
streets_list_scene_4 = setup.setup_streets_scene_4()

streets_scene_5 = pygame.sprite.Group()
streets_list_scene_5 = setup.setup_streets_scene_5()

streets_scene_6 = pygame.sprite.Group()
streets_list_scene_6 = setup.setup_streets_scene_6()

streets_scene_7 = pygame.sprite.Group()
streets_list_scene_7 = setup.setup_streets_scene_7()


lanterns_scene_1 = pygame.sprite.Group()
detectors_scene_1 = pygame.sprite.Group()
lantern_list_scene_1, detectors_list_scene_1 = setup.setup_lanterns_detectors_scene_1()

lanterns_scene_2 = pygame.sprite.Group()
detectors_scene_2 = pygame.sprite.Group()
lantern_list_scene_2, detectors_list_scene_2 = setup.setup_lanterns_detectors_scene_2()

lanterns_scene_3 = pygame.sprite.Group()
detectors_scene_3 = pygame.sprite.Group()
lantern_list_scene_3, detectors_list_scene_3 = setup.setup_lanterns_detectors_scene_3()

lanterns_scene_4 = pygame.sprite.Group()
detectors_scene_4 = pygame.sprite.Group()
lantern_list_scene_4, detectors_list_scene_4 = setup.setup_lanterns_detectors_scene_4()

lanterns_scene_5 = pygame.sprite.Group()
detectors_scene_5 = pygame.sprite.Group()
lantern_list_scene_5, detectors_list_scene_5 = setup.setup_lanterns_detectors_scene_5()

lanterns_scene_6 = pygame.sprite.Group()
detectors_scene_6 = pygame.sprite.Group()
lantern_list_scene_6, detectors_list_scene_6 = setup.setup_lanterns_detectors_scene_6()

lanterns_scene_7 = pygame.sprite.Group()
detectors_scene_7 = pygame.sprite.Group()
lantern_list_scene_7, detectors_list_scene_7 = setup.setup_lanterns_detectors_scene_7()


current_scene = "scene_1"
    
for item in lantern_list_scene_1:
    lanterns_scene_1.add(item)
for item in detectors_list_scene_1:
    detectors_scene_1.add(item)
for item in streets_list_scene_1:
    streets_scene_1.add(item)

for item in streets_list_scene_2:
    streets_scene_2.add(item)
for item in lantern_list_scene_2:
    lanterns_scene_2.add(item)
for item in detectors_list_scene_2:
    detectors_scene_2.add(item)

for item in streets_list_scene_3:
    streets_scene_3.add(item)
for item in lantern_list_scene_3:
    lanterns_scene_3.add(item)
for item in detectors_list_scene_3:
    detectors_scene_3.add(item)

for item in streets_list_scene_4:
    streets_scene_4.add(item)
for item in lantern_list_scene_4:
    lanterns_scene_4.add(item)
for item in detectors_list_scene_4:
    detectors_scene_4.add(item)

for item in streets_list_scene_5:
    streets_scene_5.add(item)
for item in lantern_list_scene_5:
    lanterns_scene_5.add(item)
for item in detectors_list_scene_5:
    detectors_scene_5.add(item)

for item in streets_list_scene_6:
    streets_scene_6.add(item)
for item in lantern_list_scene_6:
    lanterns_scene_6.add(item)
for item in detectors_list_scene_6:
    detectors_scene_6.add(item)

for item in streets_list_scene_7:
    streets_scene_7.add(item)
for item in lantern_list_scene_7:
    lanterns_scene_7.add(item)
for item in detectors_list_scene_7:
    detectors_scene_7.add(item)


if __name__ == "__main__":
    run = True
    while run:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
        
        if current_scene == "scene_1":
            functions.scene_1(screen, detectors_scene_1, streets_scene_1, lanterns_scene_1, player)
        if current_scene == "scene_2":
            functions.scene_2(screen, detectors_scene_2, streets_scene_2, lanterns_scene_2, player)
        if current_scene == "scene_3":
            functions.scene_2(screen, detectors_scene_3, streets_scene_3, lanterns_scene_3, player)
        if current_scene == "scene_4":
            functions.scene_2(screen, detectors_scene_4, streets_scene_4, lanterns_scene_4, player)
        if current_scene == "scene_5":
            functions.scene_2(screen, detectors_scene_5, streets_scene_5, lanterns_scene_5, player)
        if current_scene == "scene_6":
            functions.scene_2(screen, detectors_scene_6, streets_scene_6, lanterns_scene_6, player)
        if current_scene == "scene_7":
            functions.scene_2(screen, detectors_scene_7, streets_scene_7, lanterns_scene_7, player)

        current_scene = player.sprite.left_scene(current_scene)

        pygame.display.update()
        clock.tick(60)

    pygame.quit()