Coder Social home page Coder Social logo

admin-war's People

Contributors

dependabot[bot] avatar panggk avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

admin-war's Issues

players: implement 100hp life

This change would require changes on:

  • Players life bar percentage calculation
  • Players animation calculation (i.e. when to vibrate and when to fade out)

implement replay

some issues were encountered with state management and browser blocking on the second iteration

design: simplify state

There are too many variables in the App state that get propagated to different components. Better separation of concerns and delegation to local component states would make for a clearer design.

use setInterval?

Instead of "looping" or having useEffect triggered by different state updates it could be looped by setInterval. The main problem with this is that each interval needs to use the most updated state and that is not possible since useEffect needs to run for the state to be updated.

It can be updated using a callback instead of a value in the corresponding setter, e.g.:

          // eslint-disable-next-line no-shadow
          setPlayerLives((playerLives) => ({
            ...playerLives,
            [enemyName]: playerLives[enemyName] - 1,
          }));

But accesing calls will still get the old values.

attacks: implement history

Since attacks will happen more frequently, we would need to display them somewhere in order not to lose track. This could be a separate panel on the application, or e.g. via Twitter.

playes panel: implement "discover" pokemon

Initially, the pokemons would be "hidden", displaying the silhouette image. Once they have appeared in the main battlefield the image would change by the non-silhouette one.

Is there a way to achieve this with a PlayersPanel local state ( + callbacks?) instead of creating yet another "global" variable in App?

sometimes the game blocks

Seems to be the fact of not clearing timeouts and them being stacked/triggered forever (memory leak?):

useEffect(() => {
    const timer = () => setTimeout(() => ...some work ... , 2000);
    const timerId = timer();
    return () => {
      clearTimeout(timerId);
    };
  });

There is no need to clear timeouts unless you want to clear them early. However, it is a good practice to avoid memory leaks, for example in case that the component unmounts. The function returned by useEffect is the one that will be run on unmount.

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.