Chapter 4.3 - LightsOff Project
Turn Off Lights Project
This lesson suggests several small programming projects for enhancing the TurnOffLights app.
Hints and suggestions are provided.
Objectives: In this lesson, you will learn to :
better navigate the Thunkable online programming platform;
deepen your understanding of event-driven programming;
develop your understanding of how variables are incremented;
develop a better understanding of conditional if blocks and apps that make decisions.

Getting Ready
For this lesson you can use the project you created in the previous lesson. Start up Thunkable and open your TurnOffLights project. Then complete the programming exercises described below.
Mini Project Ideas and Hints
Here are some creative project ideas. Working in pairs/groups to complete all of them. You are encouraged to discuss your ideas for how to solve these problems with the instructor and with your partner, and other students.
Personalize the app by changing its socially useful theme to one that you like. This will require you to add your own images for the Canvas background and the Sprite.
To make this more like a real game, add a scoring feature to the app, modifying the UI so it can display changes to the user's score as it changes. Hint: Use what you learned in the Paint Pot app about incrementing a variable to implement the score feature.
If/else algorithm: Add a winning score feature that stops the game and congratulates the user when they reach a certain score. Stopping the game should include stopping the Sprite from jumping around. (Possible enhancement: Use a Speech block and have it say something when the player reaches a certain score. Or use an Alert block to pop up and congratulate the player.)
Procedural abstraction: Add a Reset button to the app that allows the player to restart the game after it's been stopped. Define a resetGame procedure to encapsulate the tasks involved in resetting the game. These would typically include setting the score back to 0 and getting the Sprite to start moving again. In addition to calling the procedure from the reset button event handler, it should be called from the when Screen1 starts handler. Make sure you use good naming conventions when you add a button to the app.
Create one or more of your own enhancements or variations for this app. Here are some ideas:
You could also implement keeping track of the number of misses -- i.e., the number of times the player failed to touch the Sprite -- and factor this into your scoring algorithm.
Challenging. Add a second image to the app to turn the game into one that forces the player to distinguish between "good" and "bad" choices. For example, if your app had a nutrition theme, perhaps one image could be a picture of a healthy food item and the other a not-so-healthy item. Perhaps the player's score decreases if they touch the "bad" choice.
Challenging: Change the speed of the mole when the player reaches a certain score. (Hint: Recall that in this app, the Mole's speed is controlled by the Timer interval.)
Last updated