Code Monkey home page Code Monkey logo

snek's Introduction

Snek

Typescript and Node console app rendition of that one snake game.

Demo

Setup

$ yarn
$ yarn run dev
$ node .

Play globally

To play globally, run this after building:

$ yarn global add file:path/to/project

Now from anywhere run

$ snek

snek's People

Contributors

aurium avatar bambutz avatar daraclare avatar denvaar avatar evless avatar kazuhirodk avatar laercios avatar louiidev avatar mahowa avatar mleko avatar purplemyst avatar vensauro avatar vinod-vs avatar vitebo avatar vypxl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

snek's Issues

Hide cursor when game is playing

'\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.

Add prettier config

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)

Rainbow snek

After the snek is over 10 in length make it animated with a rainbow effect as it moves.

Make tail flash for a moment when food is eaten by snek

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.

Run the game globally

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

Update README with latest GIF

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.

Animate rainbow effect

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. ----------

Improve performance of screen drawing

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.

Snake moves faster in vertical direction than when horizontal

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.

Make lastPressed not so global

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.