Giter Club home page Giter Club logo

super-tetris's People

Contributors

petukhov avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

super-tetris's Issues

animation-loop函数运行太频繁了

  • super-tetris.core命名空间中的animation-loop函数里面,我猜你希望的是events-chan中有事件到达的时候,这个函数执行一次。但是事实是,这个函数在没有事件到达时,也在不停的执行。问题出在 alts! 函数的使用上,这里需要的应该是从 events-chan中取出事件数据,<! 函数才是合适的。
  • animation-loop的方式循环,我认为用(go (loop ...))语句更为合适,可以试试用这段代码:
(go
  (loop [state initial-state]
    (let [last-event [(<! events-chan)]
          {:keys [should-rerender? new-state]} (update-state-after-event state last-event)]
      (.requestAnimationFrame js/window #(when should-rerender? (render new-state)))
      (recur new-state))))

替换:

((fn animation-loop [state]
   (go
     (let [last-event (alts! [events-chan] :default :nothing)
           {:keys [should-rerender? new-state]} (update-state-after-event state last-event)]
       (when should-rerender? (render new-state))
       (.requestAnimationFrame js/window (partial animation-loop new-state)))))
  initial-state)

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.