craiyon logo

A blue pixel art character with orange hands and hair jumps over red block obstacles. Blue wave patterns are at the bottom on a white background, like a retro video game.

A blue pixel art character with orange hands and hair jumps over red block obstacles. Blue wave patterns are at the bottom on a white background, like a retro video game.

erstelle bilder und grafiken für dieses spiel: import pygame import random # Initialisierung pygame.init() WIDTH, HEIGHT = 800, 400 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Pixel Runner") clock = pygame.time.Clock() font = pygame.font.SysFont(None, 40) # Farben WHITE = (255, 255, 255) BLACK = (0, 0, 0) BLUE = (0, 100, 200) RED = (200, 50, 50) GROUND_Y = HEIGHT - 50 # Spieler player = pygame.Rect(100, GROUND_Y - 50, 40, 50) player_vel_y = 0 gravity = 1 is_jumping = False # Hindernis obstacle = pygame.Rect(WIDTH, GROUND_Y - 40, 30, 40) obstacle_speed = 6 # Punkte score = 0 # Spielstatus game_active = True # Hauptschleife while True: screen.fill(WHITE) pygame.draw.line(screen, BLACK, (0, GROUND_Y), (WIDTH, GROUND_Y), 2) for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit() if game_active: # Steuerung keys = pygame.key.get_pressed() if keys[pygame.K_SPACE] and not is_jumping: player_vel_y = -15 is_jumping = True # Spielerbewegung player_vel_y += gravity player.y += player_vel_y if player.y >= GROUND_Y - player.height: player.y = GROUND_Y - player.height is_jumping = False # Hindernisbewegung obstacle.x -= obstacle_speed if obstacle.x < -30: obstacle.x = WIDTH + random.randint(0, 300) score += 1 # Kollision if player.colliderect(obstacle): game_active = False # Zeichnen pygame.draw.rect(screen, BLUE, player) pygame.draw.rect(screen, RED, obstacle) score_text = font.render(f"Punkte: {score}", True, BLACK) See more