Giter VIP home page Giter VIP logo

dumbbell's People

Contributors

graue avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

dumbbell's Issues

You can still turn 180ยฐ sometimes

Killing yourself by turning 180ยฐ is supposed to be prevented, but you can still do it. Assume you're going left. Quickly press down or up followed by right. If game logic hasn't run in between the two key-presses, you don't move vertically and so run into your tail right away.

To fix this, we should save the direction that was last advanced in (by a pixel or more after flooring), and disallow turning in the opposite of that direction.

Drop frames

requestAnimationFrame isn't guaranteed to call our callback every 1/60th of a second. We should measure how many complete frames have passed and advance the game state accordingly, so dropped frames don't make the game slow down.

Possibility for multiple "game over" dialogs

With the new ticker logic that fixed #1 and #3, I introduced a new bug: if we run multiple ticks at the time, and in one of those ticks you get a game over, we cause multiple game over dialogs or other buggy behavior. This happens because the ticker logic doesn't account for @snake-speed (which determines how many ticks have passed!) changing midway through processing ticks.

If I don't plan to ever change the snake's speed, I can make it a constant and add a proper game-over flag instead of the hack of setting snake speed to 0 when you die. Otherwise, the proper fix is probably something like a loop, recalculating number of ticks to process after each tick runs.

I can trigger this multi-game-over-dialog bug in Firefox by switching to another tab, waiting 5 or 10 seconds, then switching back. Having the tab inactive apparently suspends requestAnimationFrame callbacks, so when we switch back, a whole bunch of ticks are run at once. (Which also causes a bit of lag, maybe a problem in its own right. A fix for that would be to detect when the tab becomes inactive and pause the game. In fact, I'll file issue #5 about that after this.)

Scores

Add scores to the game and display them somewhere. Probably something like 1 point for every pixel you advance, 100 points when you get a dumbbell.

Arithmetic on Date objects

With a ClojureScript version bump I now get this:

WARNING: cljs.core/-, all arguments must be numbers, got [js/Date nil] instead. at line 129 src-cljs/dumbbell/main.cljs

In reference to (- new-time last-time) in ticker. I think the nil part of that error may be a ClojureScript bug as it just does not know the value of last-time (but does know new-time has to be a js/Date). But is it correct that I shouldn't rely on subtracting Date objects? Maybe an explicit call to .valueOf() is the way to go here.

Add a separate cljsbuild profile for advanced optimizations

Turning on advanced optimizations breaks incremental recompiling. ๐Ÿ˜ž But the advanced optimizations are kind of crucial for "deploying" to http://toxicsli.me/dumbbell/ because they make the JS file (currently) 124KB instead of 800 some. I've been going in and changing the project.clj, building, then changing it back but I think lein-cljsbuild has a feature to specify multiple builds. I should use that.

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.