My First Official Python Video Game
Well I actually just got back from a vacation so I haven’t been doing much coding but before I left I made this one program which technically counts as a video game. Its really simple and it doesn’t have graphics but it does have health points! Since I don’t know how to compile programs yet I can’t post that up here but I can post the actual code. This is in Python:
# Troll Battle
# Simulates a Fight with a Troll using random sets of damage.
import random
print("Your Hero is attacked by a massive Troll Monster.")
print("Your hero unsheathes his sword ready for batle but with little hope in his eyes.\n")
roll = random.randrange(5) + 1
health = 100
thealth = 300
while ((health > 0) and (thealth > 0)):
input("Press enter to continue.\n\n")
roll = random.randrange(5) + 1
if roll > 3:
tdamage = random.randint(10,26)
thealth -= tdamage
print("Your hero swings and damages the troll for" \
, tdamage, "damage points.")
print("The Troll's health is now", thealth, "\n\n")
if roll == 3:
damage = random.randrange(3,9)
tdamage = random.randint(7,12)
thealth -= tdamage
health -= damage
print("Your Hero swings but the troll matches his strength"
, "and you both take damage")
print("Your Hero takes", damage,"damage. His health is now", health)
print("The Troll takes", tdamage, "damage. His health is now", thealth, "\n\n")
if roll < 3:
damage = random.randint(4,15)
health -= damage
print("Your Hero swings but the Troll blocks his attack and counters,")
print("Your Hero takes", damage,"damage. His health is now", health, "\n\n")
if thealth < 0:
print("Huzzah! Your Hero has Triumphed!")
print("The Troll is vanquished")
if health < 0:
print("Your hero fought valiantly...")
print("But alas, He is no more.")
input("\n\nPress the enter key to exit.")
(Update: here is the exe download link)
(Note: Just extract the files into a folder and run the program)
Don’t expect much. I’m new to this =) =P