-
Hello! I am attempting to write my own networking code for a project I'm working on, and I'm having trouble creating more actors for the other players. I'm storing the actors as entries in a dictionary, and I've confirmed that they're there, but trying to run a for loop in the draw() function doesn't work, so I can't actually draw the actors. Any help with this is appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Nevermind, fixed it. For anyone in the same scenario as me, you can create actors from a dictionary, but it wasn't working in my case because of how my multithreaded multiplayer works. It was resetting the dictionary containing the actors every loop (due to a bug in my code), and replacing it with a new dictionary with updated positions, which wouldn't normally be an issue, but because it was running asynchronously alongside pgzero it was out of sync just enough so that every time pgzero went to draw the actors, the dictionary was empty. I blame this issue on my brain being fried because I spent 10 hours today just coding an account system, GUI to login with tkinter, and real-time networking code. (also, it's a really annoying bug to catch, considering it was a single line causing it, and no amount of debugging prints could really help with this). tl;dr |
Beta Was this translation helpful? Give feedback.
Nevermind, fixed it. For anyone in the same scenario as me, you can create actors from a dictionary, but it wasn't working in my case because of how my multithreaded multiplayer works. It was resetting the dictionary containing the actors every loop (due to a bug in my code), and replacing it with a new dictionary with updated positions, which wouldn't normally be an issue, but because it was running asynchronously alongside pgzero it was out of sync just enough so that every time pgzero went to draw the actors, the dictionary was empty. I blame this issue on my brain being fried because I spent 10 hours today just coding an account system, GUI to login with tkinter, and real-time network…