Lights Out
March 18, 2021
As a kid, I had a handheld version of this game made by Tiger. For my siblings and me, it was neat distraction for a few weeks. Now, with some help from Blender and React, I can make it myself!
Clearly, it’s not finished yet. I just wanted to put up my progress with it after a few hours. Getting React and JSX to play nicely with Hugo wasn’t much trouble, and the game’s logic is pretty straightforward. Next, I’ll add some puzzle layouts (maybe with JSON?) and some basic controls and feedback.
The JavaScript can be viewed here.
EDIT 3/23:
Added a level select and a reset button. The level select draws from a JSON file with several arrays representing board layouts. The levels aren’t really in any particular order, but they are all solvable.
There’s one bit of code I’m using that I really hate, but I can’t find a nice alternative. I need to make a deep copy of the array in use so that the original is unaltered, and the method everyone says to use is
JSON.parse(JSON.stringify(array))
This takes my nice, clean, already-JSON-compatible bool array, converts it to a string, then converts it back to a bool array. The arrays are so small that performance isn’t impacted, but the inefficiency and the poor legibility irk me. Maybe I’ll change it and write my own function that loops through the array, doing an item by item copy. If anyone knows a better method, hit me up.