Coder Social home page Coder Social logo

Snake collision about javascript-snake HOT 3 OPEN

patorjk avatar patorjk commented on August 15, 2024
Snake collision

from javascript-snake.

Comments (3)

patorjk avatar patorjk commented on August 15, 2024

That problem doesn't appear to be in the current version of the project:

https://codesandbox.io/s/github/patorjk/JavaScript-Snake?file=/index.html

Looks like this line prevents the problem:

https://github.com/patorjk/JavaScript-Snake/blob/master/js/snake.js#L279

from javascript-snake.

lilplayer6k avatar lilplayer6k commented on August 15, 2024

that line is already in the code though

from javascript-snake.

Pikabyte avatar Pikabyte commented on August 15, 2024

So I was making my own snake game for a school project and happened to notice this funny little thing. Then I decided to see if other snake games had this. It still exists, but it's less than easy to pull off. Basically, because only two inputs are stored, if you manage to input three or more inputs before the next update, you can do a 180.

stillexists

In my project, I solved this by storing them in a list instead. Realistically though, this is a minor issue, and you would only encounter this if you were deliberately trying to.

from javascript-snake.

Related Issues (20)

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.