Hey,
My program has seperate logic and a screen parts, and when I try to run them on seperate threads, the screen doesn't display anything. When run sequentially ( in a
while(true)
{
logic.loop();
display.loop();
}
loop) everything works, but when done in seperate threads (as is in the code below) - the screen is consistently black.
class main
{
static int Main(string[] args)
{
City_Generator.GameBoard city = City_Generator.CityFactory.createCity(30, 20);
Buffers.DisplayBuffer disp = new Buffers.DisplayBuffer();
Buffers.InputBuffer input = new Buffers.InputBuffer();
Buffers.SoundBuffer sound = new Buffers.SoundBuffer();
Graphic_Manager.DisplayManager display = new Graphic_Manager.DisplayManager(30 * 32, 20 * 32, 32, disp, city.Img);
Logic.GameLogic logic = new Logic.GameLogic(disp, input, sound, city, 100);
Thread logicThread = new Thread(new ThreadStart(logic.run));
Thread graphicThread = new Thread(new ThreadStart(display.run));
logicThread.Start();
graphicThread.Start();
logicThread.Join();
graphicThread.Join();
return 1;
}
}