Hi
I’ve completed both Sarven Shepard and Shine Getter,but I’m struggling to grasp a few of what I imagine are the key take aways / learning points.
My code for Shine Getter was:
loop:
coins = self.findItems()
coinIndex = 0
# Wrap this into a loop that iterates over all coins.
while coinIndex < len(coins):
coin = coins[coinIndex]
coinIndex += 1
# Gold coins are worth 3.
if coin.value == 3:
# Only pick up gold coins.
pos = coin.pos
x = pos.x
y = pos.y
self.moveXY(x, y)
What I’m finding hard to grasp is why the code doesn’t run when I use the following:
while coinIndex < 100:
or
coinIndex += coin.value
Whenever I try running the code with the above my char just sits there or I get an error. Yet as far as I can work out, they should both work?
What am I missing / not getting?