Summary of what i have added today.
Game States: Cleaned up how the game tracks whats going on. It now use actual states like PLAYING and GAME_OVER instead of just true/false flags. This makes it way easier to pause or show menus without things breaking aswell as making it easier to scale further.
Button Clicks: Created a brand new file (uiEvents.js) just to handle UI buttons and their functions.
Fixed Button Hitboxes: The “New Game” and “Share” buttons were drawn sideways on the screen (cuz they appear sideways in the spritesheets), which messed up where you could click them. I fixed the math so the click areas match the flipped width and height.
Restart Button: The “New Game” button actually works now. It clears the grid, resets the score, hands out new pieces, and starts a new game without you having to refresh the page.
Share Button: Opens the web share for your device so you can share your score. It wont show the actual web share opening in the screen recording tho, because it hides it.
This is basically the same state and click system i used in my Flappy Bird project. It makes it easier to add new buttons and their click events later on aswell as choosing what functions run in which state. It worked so well i decided to use it again. 