hi...is it allowed to have more than one tgui::Gui
if it is allowed...I wonder why menu.draw makes my program crash
here's part of the code
full code is here https://gist.github.com/Flaze07/f008e65c0c85bcf44f0c46037447f7b5
if it is allowed...I wonder why menu.draw makes my program crash
here's part of the code
Code Select
while (app_win.isOpen())
{
sf::Event event;
if (condition == Condition::start)
{
while (app_win.pollEvent(event))
{
if (event.type == sf::Event::Closed) app_win.close();
menu.handleEvent(event);
}
app_win.clear();
menu.draw();
app_win.display();
}
else if (condition == Condition::single)
{
sf::Time elapsed = clock.restart();
snake1.update(elapsed);
snake1.action();
snake1.check_apple(apple);
if (snake1.collision(app_win))
{
condition = Condition::over;
}
app_win.clear();
app_win.draw(apple.getShape());
for (auto& a : snake1.getSnake())
{
app_win.draw(a);
}
app_win.display();
}
else if (condition == Condition::multi)
{
sf::Time elapsed = clock.restart();
snake1.update(elapsed);
snake1.action();
snake1.check_apple(apple);
if (snake1.check_snake(snake2))
{
condition = Condition::over;
}
if (snake1.collision(app_win))
{
condition = Condition::over;
}
snake2.update(elapsed);
snake2.action();
snake2.check_apple(apple);
if (snake2.check_snake(snake1))
{
condition = Condition::over;
}
if (snake2.collision(app_win))
{
condition = Condition::over;
}
app_win.clear();
app_win.draw(apple.getShape());
for (auto& a : snake1.getSnake())
{
app_win.draw(a);
}
for (auto& a : snake2.getSnake())
{
app_win.draw(a);
}
app_win.display();
}
else if (condition == Condition::over)
{
while (app_win.pollEvent(event))
{
if (event.type == sf::Event::Closed) app_win.close();
over.handleEvent(event);
}
if (oldcon == Condition::multi);
app_win.clear();
over.draw();
app_win.display();
}
full code is here https://gist.github.com/Flaze07/f008e65c0c85bcf44f0c46037447f7b5