Toggling Lights with Buttons
4. Toggling Lights with Buttons
By completing this step in the Tagged Lights Puzzle tutorial, you'll learn how to toggle a group of lights based on which button the player interacts with.
By completing this step in the Tagged Lights Puzzle tutorial, you'll learn how to toggle a group of lights based on which button the player interacts with.
Toggling Lights
You’ll need to create a mapping between a button and the group of lights it should toggle when the player interacts with the button. To do this, you can map each button to the indices of the lights in the Lights array.
This example using the following mapping between buttons and lights:
- Button 1 maps to the light at index 0 and the light at index 3
- Button 2 maps to the light at index 0, the light at index 1, and the light at index 2
- Button 3 maps to the light at index 0, and the light at index 1
- Button 4 maps to the light at index 1
You can represent this mapping with an array named ButtonsToLights, where each element of ButtonsToLights is another array that holds the indices of the lights. The type of ButtonsToLights is then [][]int, to specify that ButtonsToLights is an array of integer arrays.
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.