The game sometimes does not load at the beginning

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Timofey

The game sometimes does not load at the beginning. I’m sure this is due to the while cycle, but I don’t know how to fix this problem.
project link: https://drive.google.com/file/d/1AH9ojG7YO9AWBuzBFCmbxX6mtIyYmysB/view?usp=sharing

:bust_in_silhouette: Reply From: AralC

I solved it.
In your spatial u use physics process and it has a if statement. That statement’s result is reloaidng the scene. I moved it to input(event) and now it’s working well.

To specify you have this

func _physics_process(_delta):
	if Input.is_action_just_pressed('space'):
		get_tree().reload_current_scene()

And you must change it like this

func _input(event):
	if Input.is_action_just_pressed('space'):
		get_tree().reload_current_scene()

hey I solved why someone gave me -1

AralC | 2021-01-10 12:32

I said that the game sometimes does not load at the BEGINNING and directed saying that probably because of the while cycle, where does this function?

Timofey | 2021-01-10 12:48

In spatials code

AralC | 2021-01-10 14:46

:bust_in_silhouette: Reply From: AlexTheRegent

You have infinite loop condition in your setWordsOnField function.
During initial words placement you can place words in way they overlap each other (one of the examples is [алтей, граб, астра] [[0, 3], [2, 3], [2, 5]], so граб overlaps астра by one symbol. In second loop you check that there is no words crossing. Since there is words crossing, wordCrossingCheck(words, wordsPositions, way) will always return true and it will be infinite cycle.

I have a choosePosition function in the loop that moves the word to an empty space, why doesn’t it work?

Timofey | 2021-01-10 12:54

As I already said in my previous answer to your question, you need to change your words placement algorithm to avoid calls to randi (because it might freeze a little even correct algorithm). I still don’t understand how you want to place your words, so probably it will be easier if you write me in discord (written in “about” of my profile).

AlexTheRegent | 2021-01-10 12:54