Why doesn't it load (sometimes) ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why doesn't it load (sometimes) ?

Hello world ! I made a little boids code and to make it more readable/maintainable, I decided to make a object-oriented version of it with some classes. But my class-based code has issues : - sometimes everything is fine, it loads and code does work good with no bug. - but sometimes (mainly when I re-run it even with no modifications) it just doesn't want to load and I'm stuck with a white screen. Comportement seems very luck-based to me, so I don't know how to patch this bug. Can anyone help me understand what I did wrong ? https://code.sololearn.com/WP4xUqF4V765/?ref=app

11th Dec 2019, 12:05 PM
Romain P.
Romain P. - avatar
1 Answer
+ 2
Ok I found my mistake (l.239) It's when I create my "target" I allow it to spawn anywhere on the screen but then I restrict it to be in a portion of the screen (setting it's bounds property). Problem occurs when it spawns outside of the restricted portion cause it will enter an endless loop never reaching the portion where it should be. Solution : make it spawn inside the restricted portion (I chose center of the screen) I updated the code with error and solution
11th Dec 2019, 12:37 PM
Romain P.
Romain P. - avatar