# Criando o arquivo naruto_vs_beach.py com o código do jogo
code = """
import pygame
import random
# Inicialização do Pygame
pygame.init()
# Tamanho da tela
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Naruto vs Beach")
# Cores
WHITE = (255, 255, 255)
BLUE = (135, 206, 235) # Céu
SAND = (194, 178, 128)
# Clock para controlar FPS
clock = pygame.time.Clock()
FPS = 60
# Player (Naruto) settings
player_width, player_height = 50, 70
player_x, player_y = WIDTH // 2, HEIGHT - player_height - 50
player_speed = 5
# Inimigo settings
enemy_width, enemy_height = 50, 70
enemies = []
enemy_speed = 3
spawn_timer = 0
# Ataque settings
attack = False
attack_cooldown = 0
# Font para mostrar texto
font = pygame.font.SysFont(None, 36)
def draw_player(x, y):
# Corpo do Naruto (retângulo laranja)
pygame.draw.rect(screen, (255, 140, 0), (x, y, player_width, player_height))
# Cabeça (círculo)
pygame.draw.circle(screen, (255, 224, 189), (x + player_width // 2, y - 20), 20)
def draw_enemy(x, y):
# Corpo do inimigo (retângulo vermelho)
pygame.draw.rect(screen, (255, 0, 0), (x, y, enemy_width, enemy_height))
# Cabeça (círculo)
pygame.draw.circle(screen, (139, 0, 0), (x + enemy_width // 2, y - 20), 20)
def draw_attack(x, y):
# Representa um ataque (um círculo azul na frente do player)
pygame.draw.circle(screen, (0, 0, 255), (x + player_width + 20, y + player_height // 2), 15)
def main():
global player_x, attack, attack_cooldown, spawn_timer
running = True
score = 0
while running:
screen.fill(BLUE) # Céu
pygame.draw.rect(screen, SAND, (0, HEIGHT - 100, WIDTH, 100)) # Praia (areia)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
# Movimento do player
if keys[pygame.K_LEFT] and player_x > 0:
player_x -= player_speed
if keys[pygame.K_RIGHT] and player_x < WIDTH - player_width:
player_x += player_speed
# Ataque com espaço
if keys[pygame.K_SPACE] and attack_cooldown == 0:
attack = True
attack_cooldown = 20 # Cooldown de frames para o ataque
# Atualiza ataque
if attack:
draw_attack(player_x, player_y)
attack_cooldown -= 1
if attack_cooldown <= 0:
attack = False
attack_cooldown = 0
# Spawn de inimigos
spawn_timer += 1
if spawn_timer > 60: # Spawn a cada 1 segundo
enemy_x = random.randint(0, WIDTH - enemy_width)
enemy_y = HEIGHT - enemy_height - 100
enemies.append([enemy_x, enemy_y])
spawn_timer = 0
# Movimenta inimigos
for enemy in enemies[:]:
enemy[0] += enemy_speed * (1 if enemy[0] < player_x else -1) # inimigos vão na direção do player
draw_enemy(enemy[0], enemy[1])
# Checa colisão com ataque
if attack and (player_x + player_width + 5 < enemy[0] < player_x + player_width + 50):
enemies.remove(enemy)
score += 1
# Se inimigo alcançar o player, fim de jogo
if abs(enemy[0] - player_x) < 40:
running = False
draw_player(player_x, player_y)
# Mostrar score
score_text = font.render(f"Score: {score}", True, WHITE)
screen.blit(score_text, (10, 10))
pygame.display.flip()
clock.tick(FPS)
pygame.quit()
if __name__ == "__main__":
main()
"""
file_path = "/mnt/data/naruto_vs_beach.py"
with open(file_path, "w") as f:
f.write(code)
file_path