The monsters code in there is effectively a no-op (looping over the
empty monsters list). If there was a monster in the list then you'd
(hopefully) get an error from Python because you were mutating the
monsters list while iterating over it.
I suspect what you want to do is:
monsters = []
for i in range(10):
monsters.append(monster(x=200, y=random.randint(20, 480)))
@window.event
def on_draw():
window.clear()
for M in monsters:
M.draw()
map.blit(0, 0, 0)
Richard
Nope, that only happens for dicts. With lists, it will
happily go into an infinite loop in that situation:
>>> L = [1]
>>> for i in L:
... L.append(i+1)
... print L
...
[1, 2]
[1, 2, 3]
[1, 2, 3, 4]
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6, 7]
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
... and so on until you kill it.
--
Greg