Snake monochrome (JS1024)

JS1024 is an annually held code golfing competition where you're basically required to create something creative in 1024 bytes or less of raw "JavaScript/HTML/WebGL"

I participated for JS1024 2020 competition with my First entry titled "Snake monochrome" Originally inspired by the old Nokia game going by the same name "Snake" which i used to play as far back as 2007-2008

Another entry making it Second is named "Tetris monochrome" i was compiled to do this game as a dare from my Girlfriend on June 6 the "Tetris 1984" anniversary

Third one is F1-racer it's inspired by my bestfriend who wasn't impressed with how i hooked up controls on "Tetris Monochrome" so he requested "i modify controls a bit", and i improved "input/output" by adding smooth touch input to it as requested

Snake game contains two entities. The Snake and the Apple, the Snake is an Object with properties position (vector), velocity (vector) and trial an Array of vectors each with two coordinates {x: (number), y: (number)}, as position and velocity

Same applies to the Apple, additionally the Apple has a special function named "reset", which gets called when the snake collides with it and basically resets its state and computes a new position

Apart from the two entities i added some functions for calculating circle collision detection, relaying "input/output" as well as a main game loop with functions responsible for setting scores and updating individual entities

Entities are rendered in monochrome style "dark-greenish" and "grayish", a single color is used for entities and another is used as background clear color

For the sake of simplicity under the hood all entities are composed of circles "dots"


See the Pen snake-monochrome by JOHN SWANA (@swashvirus) on CodePen.

Comments

Popular posts from this blog

What is 'this.' keyword in JavaScript

Open-graph meta data tags introdution

what is 'array.includes' function in JavaScript

How to create zip archives in nodejs