|
Hi
This week I have been continuing my work with the menues both graphically and codewise.
Our start menu that I drew all the sprites for, except the moon a bit to the left.
When it comes to the code I focused on the function that would switch from the Start menu to the How to play screen. In theory it would be really simple – when choosing How to play it would only replace the Startmenu-options sprite to the How to play-sprite, but keep the background sprites with the parallaxes that would keep on moving without being interrupted.
I started with putting an if-loop that said that if I pressed Space while marking the option How to play it would draw the How to play sprite. As you might understand it was not that simple; it only showed the How to play sprite on top of every other sprite (including the Start menu options-sprite) and while I was actively holding down Space.
What our Start menu looks like when marking How to play.
I wanted it to replace the Start menu options-sprite (not draw on top of it) so then I created a bool that I called chosenhowtoplay that started off false when I was in the Start menu but would turn to true if I pressed space while marking the How to play option in the Start menu. Then I wrote as an if-loop that it would turn back to false if I pressed space again when it was true, meaning that I would go back to the Start menu options. At the end of all those if-loops I wrote that when chosenhowtoplay is false it would draw the startmenuoptionscreen while howtoplay option was marked, and that when chosenhowtoplay was true it would draw the howtoplay screen instead.
What our How to play screen looks like.
However now it switched super fast between being false or true since i did not ahve any pressed-down-once function on the space.button, so i created another bool called previousisdown that would turn true if i pressed space while it was false and turns to false while the space button it is not down.
The How to play screen consists of only text and pictures explaining how things work – there is no options or such in it and so the ony input we need in it is Space which means “Go back to the Start menu”, and that is why I started with creating the How to play menu code before creating the Options code which will include loads of options and inputs. That is what I will start working on now, with this code as a basis.
Glhf to me! 😀

|