teach-ict.com logo

THE education site for computer science and ICT

Python code for the adventure game


NOTE: You will need to make sure that the 'print' statements on the 'IF ... Else' condition are indented after copying this into Python.

 

"""Made by Teach-ICT
My adventure game
"""

#imports
import random

#variables
greeting="welcome to the Teach-ICT adventure game."

health=100

difficulty=1

#calculations
monster_hit=int(random.randint(0,100)*difficulty)

current_health=health-monster_hit

user_name=input("Enter your first name: ")
print()
print("------------------------------")
print()

print("Hello " +user_name.title() + ", " +greeting)
print()
print("Your starting health is " + str(health) + " points.")
print()
print("You have been hit by a monster for " +str(monster_hit) + " points.")
print()
print("After being hit, your health has dropped down to " +str(current_health) + " points.")
print()
if current_health <=0:
print("You are dead! The game will now end")
else:
print("You have survived the monster attack. Let's continue playing")

 

NOTE: You will need to make sure that the 'print' statements on the 'IF ... Else' condition are indented after copying this into Python.