C
C#8mo ago
Owltávio

✅ Could anyone explain to me why, on the second time, the code is skipping the thread "animation"?

So i'm making a small turtle race for a college assignment, and while testing I discovered that after running the code for the first time, it jumpss from tt5.register into the winner's VictoryScreen and skiping the code that would represent the race. Could anyone explain what I did wrong to make that happened?
7 Replies
Owltávio
OwltávioOP8mo ago
BlazeBin - gghfoisbxulm
A tool for sharing your source code with the world!
ACiDCA7
ACiDCA78mo ago
what is inside Reset?
Owltávio
OwltávioOP8mo ago
public void Reset(){
position = 0;
rest = 0;
tired = false;
won = false;
}
public void Reset(){
position = 0;
rest = 0;
tired = false;
won = false;
}
ACiDCA7
ACiDCA78mo ago
are you ever stopping the threads? in a new run the old threads still run
Owltávio
OwltávioOP8mo ago
Oh, no How do I stop the thread?
ACiDCA7
ACiDCA78mo ago
currently to finish the thread that turtle has to win.. so after any turtle won you would have to break out of the loop thats just guessing but i think what happens is one turtle win you get into vicotryscreen then until you start the second run one of the other turles wins and therefore you go right to the next victory screens in reset you would need another flag whch you set and then check inside your while loop wo stop the loop from continuing or alternatively hava variable outside of turtle that manages if a race is currently running
Owltávio
OwltávioOP8mo ago
Okay, thanks for the help
Want results from more Discord servers?
Add your server