New here. I’m trying to play Usual Day and for some reason, towards the end of the level, a mushroom appears and an enemy appears right in line with the mushroom. The hero goes towards the enemy, getting the mushroom on the way and dies.
Defeat munchkins, collect coins. Everything as usual.
Use AND to check existence and type in one statement.
enemy = hero.findNearestEnemy()
# With AND, the type is only checked if enemy exists.
if enemy and enemy.type == “munchkin”:
# Find the nearest item.
item = hero.findNearestItem()
# Collect item if it exists and its type is “coin”.
if item and item.type == “coin”:
hero.moveXY (item.pos.x, item.pos.y);
I can have the hero move to another spot to avoid the mushroom but that’s eight lines of code and won’t complete the level.