Use the checkAndAttack function to make your code easy to read.
This function has a parameter.
An parameter is a way of passing information into a function.
def checkAndAttack(target):
# The ‘target’ parameter is just a variable!
# It contains the argument when the function was called.
if target:
hero.attack(target)
hero.moveXY(43, 34)
while True:
hero.moveXY(58, 52)
topEnemy = hero.findNearestEnemy()
# Using the checkAndAttack function with the topEnemy variable.
checkAndAttack(topEnemy)
# Move to the bottom X mark.
hero.moveXY(58, 16)
# Create a variable named bottomEnemy and find the nearest enemy.
# Use the checkAndAttack function, and include the bottomEnemy variable.
hero.moveXY(58, 16)
# Create a variable named bottomEnemy and find the nearest enemy.
checkAndAttack(target)
# Use the checkAndAttack function, and include the bottomEnemy variable.
# Create a variable named bottomEnemy and find the nearest enemy.
for this part type in bottomEnemy = hero.findNearestEnemy()
You do the equal part since its easy to find.
Hint: It is in the place where it say’s glasses or lenses. It should be below your weapon.
# Use the checkAndAttack function, and include the bottomEnemy variable.
This part write CheckAndAttack(BottomEnemy)
you will do the part in the parentheses because it is very easy since they tell you what to include in the parentheses in the hint they give you.
he/her didn’t reply yet but I gave he/her three tips that should help he/her get through the level since when I did this level I had almost the same code but I think he/her is only leaving out the bottom 3 line of code.
Use the checkAndAttack function to make your code easy to read.
This function has a parameter.
An parameter is a way of passing information into a function.
def checkAndAttack(target):
# The ‘target’ parameter is just a variable!
# It contains the argument when the function was called.
if target:
hero.attack(target)
hero.moveXY(43, 34)
while True:
hero.moveXY(58, 52)
topEnemy = hero.findNearestEnemy()
# Using the checkAndAttack function with the topEnemy variable.
checkAndAttack(topEnemy)
# Move to the bottom X mark.
hero.moveXY(58, 16)
# Create a variable named bottomEnemy and find the nearest enemy.
bottomEnemy=hero
# Use the checkAndAttack function, and include the bottomEnemy variable.
checkAndAttack
hero.moveXY(43, 34)
def checkAndAttack(target):
# The ‘target’ parameter is just a variable!
# It contains the argument when the function was called.
if target:
hero.attack(target)
hero.moveXY(43, 34)
while True:
hero.moveXY(58, 52)
topEnemy = hero.findNearestEnemy()
# Using the checkAndAttack function with the topEnemy variable.
checkAndAttack(topEnemy)
# Move to the bottom X mark.
hero.moveXY(58, 16)
# Create a variable named bottomEnemy and find the nearest enemy.
bottomEnemy=hero
# Use the checkAndAttack function, and include the bottomEnemy variable.
checkAndAttack
hero.moveXY(43, 34)