Gra w Rabaty
Gra o rabaty
import random # Inicjalizacja planszy board = [ ["#", "#", "#", "#", "#", "#", "#", "#", "#", "#"], ["#", ".", ".", ".", ".", ".", ".", ".", ".", "#"], ["#", ".", "#", "#", "#", "#", "#", "#", ".", "#"], ["#", ".", "#", ".", ".", ".", ".", "#", ".", "#"], ["#", ".", "#", ".", "#", "#", ".", "#", ".", "#"], ["#", ".", "#", ".", ".", ".", ".", "#", ".", "#"], ["#", ".", "#", "#", "#", "#", "#", "#", ".", "#"], ["#", ".", ".", ".", ".", ".", ".", ".", ".", "#"], ["#", ".", ".", ".", ".", ".", ".", ".", ".", "#"], ["#", "#", "#", "#", "#", "#", "#", "#", "#", "#"], ] # Inicjalizacja pozycji gracza player_x = 1 player_y = 1 # Inicjalizacja energii gracza player_energy = 100 # Inicjalizacja pozycji baterii battery_positions = [(random.randint(2, 8), random.randint(2, 8)) for _ in range(4)] # Inicjalizacja pozycji złych botów bot_positions = [(5, 5), (3, 7), (7, 3), (6, 8)] # Inicjalizacja ruchu Lapmana i botów player_direction = "right" bot_directions = ["up", "down", "left", "right"] # Funkcja do ruchu gracza def move_player(move): global player_x, player_y if move == "w": player_x -= 1 elif move == "a": player_y -= 1 elif move == "s": player_x += 1 elif move == "d": player_y += 1 # Funkcja do aktualizacji paska energii Lapmana def update_energy_bar(): energy_bar = "#" * (player_energy // 10) print(f"Energia Lapmana: []") # Główna pętla gry while True: # Wyświetlanie planszy for row in board: print(" ".join(row)) print(f"Energia: ") # Poruszanie gracza move = input("Gdzie chcesz się poruszyć? (w/a/s/d): ") move_player(move) # Sprawdzanie kolizji z baterią if (player_x, player_y) in battery_positions: player_energy += 20 battery_positions.remove((player_x, player_y)) # Sprawdzanie kolizji z botem if (player_x, player_y) in bot_positions: print("Złapany przez bota! Koniec gry!") break # Aktualizacja ruchu Lapmana lapman_move = random.choice(["up", "down", "left", "right"]) move_player(lapman_move) #