mardi 18 août 2020

Using State Pattern to program snake in SFML

Recently, I've tried to create Snake game in SFML. However, I also wanted to use some design pattern to make some good habits for the future programming - it was State Pattern. But - there is some problem that I am unable to solve. To make everything clear, I've tried to make several Menus - one main menu, and others, like "Options", or something like this. The first option of main menu would take player to the "Playing State". But then, the problem appears - I think the whole game should be an independent module implemented to program. So, what should I do with actual state which program is in? (for example, let's call this state "MainMenu"). Should I make additional state called "PlayingState", which would represent the whole game? How would I do it? How is it possible to add new functionality to a single state? Do you have any ideas?

Aucun commentaire:

Enregistrer un commentaire