Giter Club home page Giter Club logo

fp-games's People

Contributors

chrokh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fp-games's Issues

Apple position

The apple position can stand on a snake position.

const nextApple = state => willEat(state) ? validApplePos(state)(rndPos(state)) : state.apple
const validApplePos = (state) => (randPos) => state.snake.find( pointEq(randPos) ) === undefined ? randPos : validApplePos(state)(rndPos(state))

Predictability of validMove function

Problems:

  1. When moving right, and press down and left rapidly (within the same draw), the left will be rejected because it fails the check against the first item in the movement array. Expected behavior should be that rapid key press will perform both moves.

  2. Valid move does not check if the move is the same as the current direction, so rapid presses of key fills up the array with junk. Expected behavior is that pressing the key in the direction of travel is completely ignored.

Proposed valid move function:
const validMove = move => state =>{
let indexLast = state.moves.length - 1
let OppositeDirection = state.moves[indexLast].x == -move.x || state.moves[indexLast].y == -move.y
let SameDirection = state.moves[indexLast].x == move.x && state.moves[indexLast].y == move.y
return (!SameDirection && !OppositeDirection)
}

The above should be placed into snake.js replacing the existing const validMove. It will make the game feel much more responsive.

PS indexLast can be turned into a method and placed in base.js for modularity

Poor question

I'm trying to study your code, it is an ispiration for me.
I have a question, which is the difference between these three function?

const rnd = min => max => Math.floor(Math.random() * max) + min;

const rnd2 = (min, max) => { Math.floor(Math.random() * max) + min; }

function rnd3 (min, max) { return Math.floor(Math.random() * max) + min;}

Why you use the first one?
I try all three and they seem to have the same behavior.
I have looking for some explination but I don't understand.
I'm very nubie :(

Move action delay

If I’m on a cell A going to cell B. While still on A I press UP the snake doesn’t go UP form A it goes to B first then UP.

This is happening because previous nextSnake doesn't receive update moves.

To fix:

const next = state => {
    return {
        rows: state.rows,
        cols: state.cols,
        moves: nextMoves(state),
-       snake: nextSnake(state),
+      snake: nextSnake({...state, moves: nextMoves(state)}),
        apple: nextApple(state)
    }
}

This is improve reaction to key presses and make game feels less sluggish.

Syntax error

When running node cli I'm getting a syntax error on line 21 with the trailing comma. Removing the comma fixes the syntax error and the program runs normally.

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.