There are three kinds of dialogs used in Chips Challenge. These are the simple dialog, the message dialog, and the password dialogs.
Simple Dialog
The simple dialog just contains text and no buttons. It is used to display the level title, the hint, and the pause screen overlay. The hint and title are shown automatically and dismissed automatically based on the gameplay and the pause overlay is shown or hidden when either the game is paused or the user tries to go to a level that has not been unlocked yet.
The simple dialog, such as the hint dialog, is easily hidden within the user interface and only shows a message.
Message Dialog
The message dialog is basically the same as the simple dialog, except it has a button drawn below the text. Input from the keyboard is read to dismiss the dialog. This is used to display messages such as why Chip died or to display a summary of the level upon winning. Every 10 levels or so, an additional message (known as a decade message) will be added to the summary as well and at the end of the game some additional messages are shown.
The buttons are merely aesthetic and you can't actually click them because there is no touch input being utilized in the game. Instead, the clicking is simulated with keypresses. Either the spacebar or Enter key can be pressed to dismiss the dialog.
The Message dialog is handled by the show_message()
function inside of game.py. It handles the drawing of the dialog, listening to keyboard input, and settings/unsetting the valid keyboard command sets.
Password Dialogs
The password dialogs are used when you need to go to a specific level or just type in a password. This is the most complex type because the input fields need to be kept track of so that they can be updated if there is any input and the fields redrawn.
When they are displayed, input from the keyboard is read and the controls are updated accordingly. The fields have a type that allows for just alphabetic characters, numeric characters, or anything. This allows for easier filtering of the keys. This way you aren't able to type a letter for a level number. It also has a maximum length property in order to limit the number of characters and having it go off the screen.
Just like with the message dialog, there are some purely visual buttons at the bottom. These include OK and Cancel buttons, which are selected by pressing the Enter and Escape keys respectively.
The Password dialog is handled by the request_password()
function in game.py. It handles the drawing of the dialog, listening to keyboard input, adjusting the field parameters, and settings/unsetting the valid keyboard command sets. It also handles what to do when the user selects either OK or CANCEL.
The password dialog is to let the user input a level number and password (or in some cases, just the password). The Tab key allows switching to the next dialog and the darker border indicates the active field. Both fields allow a maximum of 9 characters, though this could be set to a smaller value. The number field only allows numerical values to be entered, whereas the password field allows alphanumeric values.
Partial updating is used to only redraw the active field when a value is changed.
Stacking Dialogs
Dialogs are kept in their own layer using a displayio group. They are able to be stacked by adding dialogs to the group and removing them as they are dismissed.
Page last edited April 09, 2025
Text editor powered by tinymce.