I’ve been debugging as I’ve been going along all day. Here is some debug info of the neighbours array…
// placed a "lamp tile"
[game.level.tiles.LampTile[x=544,y=224,width=32,height=32]]
// placed a "power tile" to the left of "lamp tile"
[game.level.tiles.LampTile[x=544,y=224,width=32,height=32],
game.level.tiles.PowerTile[x=512,y=224,width=32,height=32]]
// placed a "power tile" to the right of "lamp tile"
[game.level.tiles.LampTile[x=544,y=224,width=32,height=32],
game.level.tiles.PowerTile[x=576,y=224,width=32,height=32]]
// removed the "power tile" to the right of "lamp tile"
[game.level.tiles.LampTile[x=544,y=224,width=32,height=32]]
The only solution my friend suggested to me was to in level, add the neighbours of the “lamp tile” to the array too, so that can be checked for power tiles on the opposite side. This solution seems long winded (to me) and daunting if I added a lot of power tiles if I’d need to add neighbours for all power tiles.
P.S. No grass tiles are checked since the “updates” variable is false, which is my bad for not giving all the tiles in the source.
Edit: managed to fix the issue by doing what I said above, although I absolutely HATE the idea of having to do this since it’s so long-winded and looks super in-efficient (but I have no idea how to make this more efficient and not sure for loops would even work).
Updated level code: https://gist.github.com/AndreasElia/d2f0efb38650ca586dde#file-level-java-L50
Another edit: For some reason diagonal “power tiles” keep the “lamp tile” powered, if if I remove all of the “level[x - 1][y - 2]” parts that get added to the neighbours array.