czwartek, 15 stycznia 2015

very small python "game" thanks to Bucky

import random

class Enemy:
    life = 10
 
    def attack(self):
        print("aouch!")
        self.life -= 1
     
    def checkLife(self):
        if self.life <=0:
            print ("!!!!you are dead!!!!!")
        else:
            print (str(self.life)+ " life left")
         
alien = Enemy()
predator = Enemy()

x = random.randrange(1,11)
for i in range(x):
    alien.attack()
 
alien.checkLife()

Brak komentarzy:

Prześlij komentarz