Skip to content

game #21

Description

@hamderebihiyab-pixel

import random
import time

MINI BATTLE ROYALE

Works in OneCompiler - Python 3

health = 100
ammo = 10
medkits = 2
enemies = 5
shield = 0
storm = 100

print("=" * 40)
print(" MINI BATTLE ROYALE")
print("=" * 40)
print()
print("You jump from the Battle Bus!")
input("Press ENTER to land...")

print("\n🪂 You landed!")
print("You have 100 HP and 10 bullets.")

while health > 0 and enemies > 0:

print("\n" + "-" * 40)
print("❤️ Health:", health)
print("🛡️ Shield:", shield)
print("🔫 Ammo:", ammo)
print("💊 Medkits:", medkits)
print("👾 Enemies remaining:", enemies)
print("🌀 Storm:", storm, "%")
print("-" * 40)

print("\nWhat do you want to do?")
print("1. 🔫 Shoot")
print("2. 🔎 Search for loot")
print("3. 💊 Use medkit")
print("4. 🏃 Hide")
print("5. 🚪 Quit")

choice = input("\nChoose: ")

# SHOOT
if choice == "1":
    if ammo <= 0:
        print("❌ You're out of ammo!")
        continue

    ammo -= 1
    hit = random.randint(1, 100)

    if hit <= 70:
        damage = random.randint(20, 40)
        print("💥 HIT! You dealt", damage, "damage!")

        if random.randint(1, 100) <= 30:
            print("🎯 HEADSHOT!")
            damage += 20

        # Enemy is defeated
        if damage >= 30:
            enemies -= 1
            print("💀 Enemy eliminated!")
        else:
            print("👾 Enemy is still alive!")
    else:
        print("💨 You missed!")

# LOOT
elif choice == "2":
    loot = random.choice(["ammo", "shield", "medkit", "nothing"])

    if loot == "ammo":
        amount = random.randint(3, 8)
        ammo += amount
        print("🎒 You found", amount, "bullets!")

    elif loot == "shield":
        amount = random.randint(10, 30)
        shield += amount
        print("🛡️ You found", amount, "shield!")

    elif loot == "medkit":
        medkits += 1
        print("💊 You found a medkit!")

    else:
        print("😢 Nothing here...")

# MEDKIT
elif choice == "3":
    if medkits > 0:
        if health < 100:
            medkits -= 1
            health += 30

            if health > 100:
                health = 100

            print("💚 You used a medkit!")
        else:
            print("❤️ Your health is already full!")
    else:
        print("❌ You don't have any medkits!")

# HIDE
elif choice == "4":
    print("🏃 You hide behind a tree...")
    if random.randint(1, 100) <= 60:
        print("😎 The enemy didn't see you!")
    else:
        print("👀 The enemy spotted you!")

# QUIT
elif choice == "5":
    print("You left the match.")
    break

else:
    print("❌ Invalid choice!")
    continue

# ENEMY ATTACK
if enemies > 0:
    if random.randint(1, 100) <= 50:

        damage = random.randint(10, 25)

        if shield > 0:
            shield_damage = min(shield, damage)
            shield -= shield_damage
            damage -= shield_damage
            print("🛡️ Your shield absorbed", shield_damage, "damage!")

        if damage > 0:
            health -= damage
            print("🔴 Enemy attacked! You lost", damage, "HP!")

    else:
        print("😎 The enemies are searching for you...")

# STORM SHRINKS
storm -= random.randint(5, 15)

if storm < 0:
    storm = 0

if storm <= 40:
    storm_damage = random.randint(5, 15)
    health -= storm_damage
    print("🌀 THE STORM IS CLOSING!")
    print("You took", storm_damage, "storm damage!")

time.sleep(0.5)

GAME OVER

print("\n" + "=" * 40)

if enemies == 0 and health > 0:
print("🏆 VICTORY ROYALE! 🏆")
print("You eliminated everyone!")
elif health <= 0:
print("💀 YOU DIED!")
print("Better luck next time!")
else:
print("👋 GAME OVER!")

print("=" * 40)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions