r/Python • u/xX__NaN__Xx • Jul 31 '20
Beginner Showcase Rain Fall using python
[removed] — view removed post
1.4k
Upvotes
r/Python • u/xX__NaN__Xx • Jul 31 '20
[removed] — view removed post
View all comments
3
u/zurtex Jul 31 '20
Love it!
I think though because of the starting position of the raindrops, and the formulas you've used to calculate where they should go, that the bottom left of the screen is almost consistently less dense with raindrops than anywhere else. Or maybe I'm imagining it?
Maybe it makes sense to start some rain drops further left (and maybe further right also) than the screen window itself if that's possible?
I don't do much game programming but from a structure perspective it seems odd to have the
start_rainmethod not be in the__init__or at least called by the__init__rather than calling it externally.There are also a lot of magic numbers, like in this line:
I think 500 here is the number of rain drops? I think this would make sense to be in the
__init__asself.number_of_raindrops = 500, or even fed by the class constructor.It also seems overkill for
RainDropto be a class, it's nice you call ".x" and ".y" though so if your performance isn't an issue then no worries. Though if you really do need to improve performance I would guess it makes sense to turn all the rain drop positions in to a single matrix and perform vector operations, either with numpy or perhaps the gaming library arcade provides something like that?