Code Monkey home page Code Monkey logo

grid-snake's People

Contributors

jouni-kantola avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

tomwalsh96

grid-snake's Issues

Only one heart can be on a one-way street

Two hearts cannot be one-way streets (52e0918). It would make it impossible to clear the level. One heart can, as that can be picked up last.

When getting to higher levels, the risk of surrounding hearts with stops increases.

Don't spawn stops directly infront of snake

If stops are spawned directly infront of snake, it'd be impossible to avoid them.

This issue has comes in two nuances; start of game (edddeae) and start of new level:

  • Cannot start the game on the left (even if wrapping) nor right of stop
    If would start on left, would directly collide
    If would start on right, tail would collide

  • Cannot spawn stop directly adjacent of snake
    If directly in next cell (considering direction), would directly collide
    Consider tail length when spawning (should also consider tail's length), to not collide tail with stop

    grid-snake/src/index.js

    Lines 122 to 132 in edddeae

    if (useHip)
    new Array(gameState.levelConfig.stops).fill("stop").forEach(_ => {
    const stop = ensureFree(0, gameState.numberOfCells, [
    gameState.head,
    ...gameState.tail,
    ...gameState.hearts,
    ...gameState.stops
    ]);
    gameState.stops.push(stop);
    cells[stop].classList.add("stop");
    });

Snake can't go backwards

Direction should only be updated from horizontal to vertical and vice versa. Currently one can go in opposite direction, which results in immediate tail crash.

PWA

Enable running as fullscreen PWA.

Base level speeds on grid size

Instead of a hardcoded list of update timings (42b7590), base speed on level + grid size.

In hip mode, an even more elaborate way would be to include the ratio of open/blocked cells.

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.