commit 22833dc2d3969b98804b2862f09a7977cb7b73f0 Author: Loxnebot Date: Tue Feb 10 23:22:03 2026 +0200 da diff --git a/images/back.png b/images/back.png new file mode 100644 index 0000000..2b5f6ef Binary files /dev/null and b/images/back.png differ diff --git a/images/character1.png b/images/character1.png new file mode 100644 index 0000000..272febd Binary files /dev/null and b/images/character1.png differ diff --git a/images/character2.png b/images/character2.png new file mode 100644 index 0000000..2cc57f7 Binary files /dev/null and b/images/character2.png differ diff --git a/images/door.png b/images/door.png new file mode 100644 index 0000000..2b73718 Binary files /dev/null and b/images/door.png differ diff --git a/images/wall.png b/images/wall.png new file mode 100644 index 0000000..976b8dd Binary files /dev/null and b/images/wall.png differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..51280de --- /dev/null +++ b/main.py @@ -0,0 +1,73 @@ +import pygame +import sys +pygame.init() + +CLOCK = pygame.time.Clock() +SCREEN = pygame.display.set_mode((1000, 800)) + +X_POS, Y_POS = 100, 700 +Y_GRAVITY = 1 +JUMP_HEIGHT = 20 +Y_VELOCITY = 20 +jumping = False + +STANDING_SURFACE = pygame.transform.scale(pygame.image.load("images/character1.png"), (48, 64)) +JUMPING_SURFACE = pygame.transform.scale(pygame.image.load("images/character2.png"), (48, 64)) +BACKGROUND = pygame.image.load("images/back.png") + +crest = STANDING_SURFACE.get_rect(center = (X_POS, Y_POS)) + +door_image = pygame.image.load("images/door.png") +door_rect = door_image.get_rect(center = (800, 700)) +wall_image = pygame.image.load("images/wall.png") +wall_right = pygame.Rect(1000, 0, 1, 800) +wall_left = pygame.Rect(0, 0, 1, 800) + +while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + + keys_pressed = pygame.key.get_pressed() + + if keys_pressed[pygame.K_SPACE]: + + jumping = True + SCREEN.blit(wall_image, wall_right) + SCREEN.blit(wall_image, wall_left) + SCREEN.blit(BACKGROUND, (0, 0)) + SCREEN.blit(door_image, door_rect) + + if crest.colliderect(wall_right): + X_POS -= 5 + if crest.colliderect(wall_left): + X_POS += 5 + + if keys_pressed[pygame.K_RIGHT] or keys_pressed[pygame.K_d]: + X_POS += 5 + + if keys_pressed[pygame.K_LEFT] or keys_pressed[pygame.K_a]: + X_POS -= 5 + + + if jumping: + Y_POS -= Y_VELOCITY + Y_VELOCITY -= Y_GRAVITY + if Y_VELOCITY < -JUMP_HEIGHT: + jumping = False + Y_VELOCITY = JUMP_HEIGHT + crest = JUMPING_SURFACE.get_rect(center = (X_POS, Y_POS)) + SCREEN.blit(JUMPING_SURFACE, crest) + else: + crest = STANDING_SURFACE.get_rect(center = (X_POS, Y_POS)) + SCREEN.blit(STANDING_SURFACE, crest) + + if crest.colliderect(door_rect) and keys_pressed[pygame.K_e]: + print("You win!") + pygame.quit() + sys.exit() + + + pygame.display.update() + CLOCK.tick(60) \ No newline at end of file