Typescript and Node console app rendition of that one snake game.
$ yarn
$ yarn run dev
$ node .
To play globally, run this after building:
$ yarn global add file:path/to/project
Now from anywhere run
$ snek
Node Snek
When running the game in windows in VS Code.
'\x1b[?25l'
will hide the cursor.
'\x1b[?25h'
will show the cursor (need to run this when the game is exited either via ctrl-c or if the snek dies.
I'm noticing as different people are making pull requests, there's not a consensus on how to format the code. Please add a prettier config file to this project so that everyone who contributes follows the same standards.
We should probably also have a pre-commit hook as well that enforces prettier to run? (https://prettier.io/docs/en/precommit.html)
After the snek is over 10 in length make it animated with a rainbow effect as it moves.
Find a way to add music, like "beep beep boop beep bop" while the game is playing.
Update the gif to show what happens when the snek tuns from < 10 in length to > 10 in length
Might be a cool animation to add if when you get a piece of food the tail of the snake flashes for a like 1 second or so. By "tail" I mean the last character of the tail. This would help emphasize that the snake has grown.
It might be easy to do this using an ANSI code to flash a character. Not sure though.
Please update the gif in the README to reflect the changes as part of your PR.
install the script as global with:
$ yarn global add file:/home/snek
and run with
$ snek
if publish the compiled package is possible run with npx
The GIF in the readme is out of date again based on the latest changes. Please update the gif to reflect the latest features of the game.
I think the rainbow animation could be improved. Currently, the snake's color turns from green to rainbow instantaneously once it has eaten 10 pieces of food.
I think it would be even better if the snake had a "shimmer" rainbow effect every couple of seconds after it has eaten 10 pieces of food.
What do I mean by "shimmer"? I would like the rainbow effect to begin at the front of the snake, and move to the back. For example, if -
represents the normal green snake body, and *
represents a rainbow color, the rainbow effect would travel along the body beginning at the head and ending at the tail.
1. ----------
2. *---------
3. **--------
4. ***-------
5. ****------
6. *****-----
7. -*****----
8. --*****---
9. ---*****--
10. ----*****-
11. -----*****
12. ------****
13. -------***
14. --------**
15. ---------*
16. ----------
Find a way to better type the vimMapping
variable. I just used any
for now.
I think process.stdout and process.stdin would provide better performance in terms of rendering the view. Instead of using console.log
as the function that draws the game scene on each loop tick, try using process.stdout instead to see if it looks better.
Would be awesome to see a game over animation
When tapping keys quickly enough it is possible to turn around in place and lose game
Nothing at this point is covered by tests.
One not very nice side effect is that since console cells are taller than they are wide, the movement of the snake appears faster when moving vertically.
I'm not sure if there's a "code solution" for this, but if anyone has any bright ideas, I am open to suggestions.
lastPressed
is a global variable because it's used inside gameLoop
which is run recursively, but it's mutated from the key event process handler. I'm not sure how to make this not global yet.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.