What wrong with this player class

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 465 Views - Last Post: 19 August 2014 - 06:02 PM Rate Topic: -----

#16 jgrimmie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 18-August 14

Re: What wrong with this player class

Posted 19 August 2014 - 11:30 AM

Ok so after some quick research this is what I have come up with is this correct?


# a python game for learning
	
class Player():
	#health = 100
	#armor = 100
	#ammo = 100
	
	def __init__(self, name="unknown", health=100, armor=100, ammo=100):
		self.name = name 
		self.health = health
		self.armor = armor 
		self.ammo = ammo
		
	def incoming_damage(self):
		if self.armor > 0:
			self.armor = self.armor - 25
			print "Your armor has been reduced by: 25"
			return self.armor
		elif self.armor < 0:
			self.health = self.health - 10
			print "Your health has been reduced by: 10"
			return self.health
		else:
			return 0;
	
	


player1 = Player()
	


while player1.health > 0:
	print "_____________________________________________________________"
	hud = "Your current health is: %d Your current armor is: %d and you have %d rounds \nof ammunition remaining." % (player1.health, player1.armor, player1.ammo)
	print "Main game loop running!"	
	print hud
	player1.incoming_damage()
	hud = "Your current health is: %d Your current armor is: %d and you have %d rounds \nof ammunition remaining." % (player1.health, player1.armor, player1.ammo)
	print hud
	
	print "_____________________________________________________________"
	player1.health = 0



Was This Post Helpful? 0
  • +
  • -

#17 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3459
  • View blog
  • Posts: 11,716
  • Joined: 12-December 12

Re: What wrong with this player class

Posted 19 August 2014 - 06:02 PM

The first thing to do is to run it. Does it work?
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2