Apreche/Project-DORF

Render Bug

amelim opened this issue · 3 comments

andrew@andrew-laptop:~/code/dorf/Project-DORF$ python game.py
Seeding plasma fractal @ 202319840224215132916437331412974325532
Seeding meteor @ 157042387746432895965420367951058656968
Traceback (most recent call last):
File "game.py", line 173, in
dorf = Game()
File "game.py", line 43, in init
self.update_terrain_surf()
File "game.py", line 69, in update_terrain_surf
terrainNode.contents.render(rect, self.terrainSurf)
File "/home/andrew/code/dorf/Project-DORF/terrain/init.py", line 22, in render
surface.fill(color, rect)
TypeError: invalid color argument

This wouldn't happen if we had strong typing! lol

Yeah, it looks like Alex's colors are calculated using floating point, and although I'd presume they're cast back to integers to make RGB values, there's probably rare circumstances where you get a value of -1 or 256 or the like.

Fixed, trivially. In fact, there was already a line of code for bounding the RGB values to [0, 255], but for some reason it was only in one of two cases in an if statement.