I have a programing question that isn't clarified by the app if its OK to ask here:
In lesson 14 the practice where we make the robot take half damage, the if statement where we make the robot take damage half damage if their level is above level 2 only works if that if statement is the first thing written in the take_damage function. Why does it only work in that order.
Example:
var level = 3
var health = 100
var max_health = 100
func take_damage(amount):
health -= amount
if health < 0:
health = 0
if level > 2:
amount *= 0.5
^ This doesn't work.========================
var level = 3
var health = 100
var max_health = 100
func take_damage(amount):
if level > 2:
amount *= 0.5
health -= amount
if health < 0:
health = 0
^ This does work.