iiitl / snake-game-js

0 stars 43 forks source link

added game over on snake biting itself functionality. ISSUE#4 #28

Closed imranasumbul closed 5 months ago

imranasumbul commented 5 months ago

Made two separate functions collidesWithItself( ) and isDirectionReversed( ) to add the functionality of ending game whenever any of these two things happen. Attempted to change the codebase minimally by making two separate functions and an object to track the initialDirection of movement of the snake.

Screenshot 2024-03-16 040207

Screenshot 2024-03-16 041351