[gallery ids="4060,4061,4062,4063,4064,4065" type="circle"]
While not very exciting from the gamer standpoint, the information and credits screens are really important for several reasons. The main one being that it tells you how to play the game. It also lets you know how to contact the developer and who made the game. In the event you want to find more great material to play with!
Essentially, I have set up a scrolling screen that scrolls information over and over again. Pretty boring. However, I found a useful gem that I'd like to share with you here.
You see, as the information scrolls by, you might decide to click a button to do something, e.g., go back to the main menu, start the game, or what not. Well, the original method I was using was:
- Loop through displayed data.
- Check if they clicked a button.
- Add 1.5 second delay.
This is a problem because you may have to hold the button for 1.5 seconds before it is picked up by the program. So, how do we include a delay, but constantly check for button presses? Well, with a "while" loop of course! Check it out:
``` code gameDelay = 0; while (gameDelay < 2000){ // Add a delay in the loop. delay(1); gameDelay++; lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key){ // depending on which button was pushed, we perform an action case btnSELECT:{ gameState = 0; gameLineNum = 0; break; } } }
```
So, instead of 2 seconds of delay all at once, I have a while loop that delays 1 ms, checks for button pushes, and then repeats for 2000 times, or roughly 2 seconds. This allows the player to press the button at any time, and only delays by 1 ms before reading it. Not only is this more functional, but it looks cooler in code too!
You can check out the full commit for the credits screen and info screens on my GitLab if you want more information.
Linux - keep it simple.