Loading plantmanager.py +10 −1 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ class Plant: self.pot = 5 self.timelastgrown = time.time() self.health = 50 self.plantwidth = 0 self.screen = None return Loading @@ -23,6 +24,8 @@ class Plant: self.heal() if self.food > 0 and self.water > 0 and self.height < self.pot: self.height += 1 if self.plantwidth < self.pot // 2 - 1: self.plantwidth += 1 if self.health <= 0: self.screen.update("Your plant died.") return Loading Loading @@ -118,10 +121,16 @@ class Screen: plantcolour = self.plantokcolour if self.plant.health < 50: plantcolour = self.plantbadcolour plantwidth = self.plant.plantwidth for i in range(self.plant.height): line -= 1 if line >= 0: if line % 2 == 0: self.stdscr.addstr(line, plantloc, "|", plantcolour) else: leaves = "/" + "-" * plantwidth + "|" + "-" * plantwidth + "\\" self.stdscr.addstr(line, plantloc - plantwidth - 1, leaves, plantcolour) plantwidth -= 1 for i in range(line): line -= 1 if line >= 0: Loading Loading
plantmanager.py +10 −1 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ class Plant: self.pot = 5 self.timelastgrown = time.time() self.health = 50 self.plantwidth = 0 self.screen = None return Loading @@ -23,6 +24,8 @@ class Plant: self.heal() if self.food > 0 and self.water > 0 and self.height < self.pot: self.height += 1 if self.plantwidth < self.pot // 2 - 1: self.plantwidth += 1 if self.health <= 0: self.screen.update("Your plant died.") return Loading Loading @@ -118,10 +121,16 @@ class Screen: plantcolour = self.plantokcolour if self.plant.health < 50: plantcolour = self.plantbadcolour plantwidth = self.plant.plantwidth for i in range(self.plant.height): line -= 1 if line >= 0: if line % 2 == 0: self.stdscr.addstr(line, plantloc, "|", plantcolour) else: leaves = "/" + "-" * plantwidth + "|" + "-" * plantwidth + "\\" self.stdscr.addstr(line, plantloc - plantwidth - 1, leaves, plantcolour) plantwidth -= 1 for i in range(line): line -= 1 if line >= 0: Loading