tresinformal / drakkar

The tresinformal video game called 'Drakkar'
GNU General Public License v3.0
11 stars 4 forks source link

[Menu] Allow the game to switch between views #488

Closed TheoPannetier closed 2 years ago

TheoPannetier commented 2 years ago

So far, the game runs either game_view, menu_view, or options_view, then exits. Eventually, we want to be able to switch back and forth between windows, with the Menu as a central hub:

flowchart_view_mode

It's time to try and think of how this can be implemented 🤔

TheoPannetier commented 2 years ago

Here's a proposition to implement this:

https://github.com/tresinformal/game/blob/f581d4651fa309ef6b99b8dcab42964b84ef1102/main.cpp#L159-L238

TheoPannetier commented 2 years ago

Probably solved after

are solved. Probably.

TheoPannetier commented 2 years ago

It seems to work for default (i.e, running the game), but not when starting with the menu or options screens yet.

TheoPannetier commented 2 years ago

Ok, there's an issue with how variable next_view is handled by the switch. Seems like every case is matched, including the error one?

TheoPannetier commented 2 years ago

Progress: the while loop actually works as intended. The issue is that we declare all _view classes at once. The program creates one window for each of them, even if they're not used yet. But that's a different problem than the scope of this issue, so I'll close here :)