diff --git a/main.py b/main.py index cc7d359..135fdd6 100644 --- a/main.py +++ b/main.py @@ -138,10 +138,65 @@ FONT, SIZE = 'comicsansms', 14 programIcon = pygame.image.load('icon.png') pygame.display.set_icon(programIcon) pygame.display.set_caption('Hell Circus') +font = pygame.font.SysFont(FONT, SIZE) screen_info = pygame.display.Info() -screen = pygame.display.set_mode((1920, 1080), pygame.FULLSCREEN) -transparent = (255, 0, 128) +screen = pygame.display.set_mode((1920, 1080), vsync=1) +pygame.display.set_caption("Simple platformer") clock = pygame.time.Clock() -hwnd = pygame.display.get_wm_info()["window"] +deltatime = 0 +running = True -font = pygame.font.SysFont(FONT, SIZE) \ No newline at end of file +# Buttons +play_button = Button("close_up.png", "close_over.png", (125, 3)) +continue_button = Button("shuffle_up.png", "shuffle_over.png", (110, 3)) +menu_button = Button("hint_up.png", "hint_over.png", (95, 3)) + +walls = pygame.sprite.Group(Wall("white", (1280, 20), (640, 0)), Wall("white", (1280, 20), (640, 720)), + Wall("white", (20, 720), (0, 360)), Wall("white", (1280, 20), (1280, 720)), + Wall("white", (200, 20), (640, 360)), Wall("white", (20, 200), (640, 360)), + Wall("white", (1280, 20), (1280, 320))) + +player_group = pygame.sprite.GroupSingle(Player("red", (100, 100), (200, 600), walls)) +camera = Camera(player_group.sprite, (300, 200)) + +all_sprites = pygame.sprite.Group() +all_sprites.add(player_group, walls) + +while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + screen.fill("black") + + camera.update(deltatime, all_sprites) + player_group.update(deltatime) + + all_sprites.draw(screen) + + pygame.display.flip() + + deltatime = clock.tick(FPS) / 1000 + +pygame.quit() + +while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_ESCAPE: + running = False + + background_img_image = pygame.image.load(BACKGROUND_IMAGE).convert_alpha() + screen.blit(background_img_image, (0, 0)) + + mouse_pos = pygame.mouse.get_pos() + + play_button.update(mouse_pos) + continue_button.update(mouse_pos) + menu_button.update(mouse_pos) + + screen.blit(play_button.image, play_button.rect) + screen.blit(continue_button.image, continue_button.rect) + screen.blit(menu_button.image, menu_button.rect)