Untitled
import random import time def start_game(): player_health = 100 player_inventory = [] player_position = (random.randint(0, 100), random.randint(0, 100)) # Random start position opponent_health = 100 zone_radius = 1000 # Starting safe zone radius players = 100 # Total players in the match while players > 1 and player_health > 0: # Game update loop print("The safe zone is shrinking.") time.sleep(5) zone_radius -= 10 # Safe zone shrinks over time if zone_radius < 200: print("The safe zone is very small! Find a safe area.") # Player Actions print("Player at position:", player_position) action = input("What do you want to do? (Move/Find Weapon/Fight/Hide): ").lower() if action == "move": direction = input("Which direction? (north/south/east/west): ").lower() if direction == "north": player_position = (player_position[0], player_position[1] + 1) elif direction == "south": player_position = (player_position[0], player_position[1] - 1) elif direction == "east": player_position = (player_position[0] + 1, player_position[1]) elif direction == "west": player_position = (player_position[0] - 1, player_position[1]) print(f"Player moved to {player_position}") elif action == "find weapon": weapon = random.choice(["Pistol", "Rifle", "Shotgun", "Medkit"]) player_inventory.append(weapon) print(f"Player found a {weapon}!") elif action == "fight": if random.random() > 0.5: # Random chance of hitting the opponent damage = random.randint(10, 20) opponent_health -= damage print(f"You hit the opponent! Damage dealt: {damage}. Opponent health: {opponent_health}") else: print("You missed the shot!") elif action == "hide": print("You hide in a building or behind cover to wait for a better opportunity.") # Random event: Another player may engage in combat if random.random() < 0.2: # 20% chance to encounter another player print("Another player appears nearby!") if random.random() < 0.5: # 50% chance the other player is aggressive print("The enemy player attacks you!") damage = random.randint(10, 25) player_health -= damage print(f"Player health: {player_health}") # Check if the player is still alive and within the safe zone if player_health <= 0: print("You have been eliminated.") break if zone_radius < 50 and player_position[0] > 50: # Random logic for zone constraint print("You are outside the safe zone! Taking damage!") player_health -= 10 # Final check: Is there only one player left? players -= 1 # For simplicity, just reducing the player count each loop print(f"Remaining players: {players}") if player_health > 0: print("Congratulations! You have won the match.") else: print("Game Over! You were eliminated.") start_game()
Leave a Comment