#20 Level Core iterate on float values

v_0.9.0
open
nobody
None
1
2012-12-26
2012-12-26
Bbp
No

The level No 35 - Core (version 1.0.0 found on Ubuntu repositories) as 3 "for" loops that iterate on float values instead of integer, in the create attribute of the level creation (file py/levels/core.py). My knowledge of python is not that good, but I think the programmer was trying to achieve the following:

s = world.getSize()

for y in range (int(-s.y/2+1.5), int(s.y/2+0.5), 2):
    for x in range (int(-s.x/2+1.5), int(s.x/2+0.5)):
        for z in range (int(-s.z/2+1.5), int(s.z/2+0.5)):
            world.addObjectAtPos (KikiStone (), world.decenter (x, y, z))

Note the values in the "for" loops are cast to int before iteration. As long as I know, "for" loops can not iterate on floats, even if the value round to a int (2.0 is not a int).

Discussion


Log in to post a comment.