Flappy Bird: is there a way to find the spawn - rate of the poles?Best way to find if an item is in a JavaScript array?Very Advanced Javascript WYSIWYG editorcanvas drawImage doesn't draw images the first timerequestAnimFrame can't give a constant frame rate, but my physics engine needs itContinuous poling with javascript - will this way workIframe nomenucontext - Modify img tag after creationImage Flickering In Canvas GameTraining Neural Network to play flappy bird with genetic algorithm - Why can't it learn?Correct way to spawn a node scriptSimple way to spawn external process

Why does this query, missing a FROM clause, not error out?

How to avoid typing 'git' at the begining of every git command

Does putting salt first make it easier for attacker to bruteforce the hash?

Solving ‘Null geometry…’ error during distance matrix operation?

Should I refuse to be named as co-author of a low quality paper?

Electricity free spaceship

Do you have to have figures when playing D&D?

Why AM-GM inequality showing different results?

bash vs. zsh: What are the practical differences?

What would be the way to say "just saying" in German? (Not the literal translation)

Why did Intel abandon unified CPU cache?

Is there a set of positive integers of density 1 which contains no infinite arithmetic progression?

Is Lambda Calculus purely syntactic?

With Ubuntu 18.04, how can I have a hot corner that locks the computer?

Has there been a multiethnic Star Trek character?

How to publish items after pipeline is finished?

What differences exist between adamantine and adamantite in all editions of D&D?

Non-aqueous eyes?

Ability To Change Root User Password (Vulnerability?)

If a Variant Human is Reincarnated, would they lose the feat and skill proficiency they started with?

What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?

Getting UPS Power from One Room to Another

Does the new finding on "reversing a quantum jump mid-flight" rule out any interpretations of QM?

Is it safe to change the harddrive power feature so that it never turns off?



Flappy Bird: is there a way to find the spawn - rate of the poles?


Best way to find if an item is in a JavaScript array?Very Advanced Javascript WYSIWYG editorcanvas drawImage doesn't draw images the first timerequestAnimFrame can't give a constant frame rate, but my physics engine needs itContinuous poling with javascript - will this way workIframe nomenucontext - Modify img tag after creationImage Flickering In Canvas GameTraining Neural Network to play flappy bird with genetic algorithm - Why can't it learn?Correct way to spawn a node scriptSimple way to spawn external process






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have made a working Flappy Bird game, but the green poles are spawning in a weird way. I have done it like this:



  • frameCount is a p5.js variable counting the frames

  • draw is a p5.js function that will be done every frame

 let game_speed = 1;
let max_speed = 1000;
let spawn_rate = Math.round(max_speed / game_speed);
function draw()
if(frameCount % spawn_rate === 0)
generateNewPole();
game_speed += (game_speed < max_speed / 10)? 0.001 : 0;
spawn_rate = Math.round(max_speed / game_speed);



I have tried the following formulas for the spawn_rate :




  • Math.round(max_speed - game_speed)



    • This didn't work even close to good



  • Math.round(max_speed / game_speed)



    • This worked ok, but I have random big gaps everywhere



  • Math.round((max_speed - game_speed) / game_speed)



    • This worked also quite well, except for random gaps here too



  • Math.round((max_speed - game_speed) / (max.speed / game.speed))



    • The poles spawned at a god-speed rate



  • Math.round(max_speed / Math.round(game_speed))



    • Also random gaps



  • if(Math.round(frameCount * game.speed) % max_speed === 0)



    • Yeah... not a single pole spawned at all


For the second and third things I tried (see above), I expected them to work, but there are still spaces. This might be because of JavaScript's way of handling decimal numbers (It sucks at it) or I am just dumb and doing something completely wrong



edit: here is a link to my code










share|improve this question






























    0















    I have made a working Flappy Bird game, but the green poles are spawning in a weird way. I have done it like this:



    • frameCount is a p5.js variable counting the frames

    • draw is a p5.js function that will be done every frame

     let game_speed = 1;
    let max_speed = 1000;
    let spawn_rate = Math.round(max_speed / game_speed);
    function draw()
    if(frameCount % spawn_rate === 0)
    generateNewPole();
    game_speed += (game_speed < max_speed / 10)? 0.001 : 0;
    spawn_rate = Math.round(max_speed / game_speed);



    I have tried the following formulas for the spawn_rate :




    • Math.round(max_speed - game_speed)



      • This didn't work even close to good



    • Math.round(max_speed / game_speed)



      • This worked ok, but I have random big gaps everywhere



    • Math.round((max_speed - game_speed) / game_speed)



      • This worked also quite well, except for random gaps here too



    • Math.round((max_speed - game_speed) / (max.speed / game.speed))



      • The poles spawned at a god-speed rate



    • Math.round(max_speed / Math.round(game_speed))



      • Also random gaps



    • if(Math.round(frameCount * game.speed) % max_speed === 0)



      • Yeah... not a single pole spawned at all


    For the second and third things I tried (see above), I expected them to work, but there are still spaces. This might be because of JavaScript's way of handling decimal numbers (It sucks at it) or I am just dumb and doing something completely wrong



    edit: here is a link to my code










    share|improve this question


























      0












      0








      0








      I have made a working Flappy Bird game, but the green poles are spawning in a weird way. I have done it like this:



      • frameCount is a p5.js variable counting the frames

      • draw is a p5.js function that will be done every frame

       let game_speed = 1;
      let max_speed = 1000;
      let spawn_rate = Math.round(max_speed / game_speed);
      function draw()
      if(frameCount % spawn_rate === 0)
      generateNewPole();
      game_speed += (game_speed < max_speed / 10)? 0.001 : 0;
      spawn_rate = Math.round(max_speed / game_speed);



      I have tried the following formulas for the spawn_rate :




      • Math.round(max_speed - game_speed)



        • This didn't work even close to good



      • Math.round(max_speed / game_speed)



        • This worked ok, but I have random big gaps everywhere



      • Math.round((max_speed - game_speed) / game_speed)



        • This worked also quite well, except for random gaps here too



      • Math.round((max_speed - game_speed) / (max.speed / game.speed))



        • The poles spawned at a god-speed rate



      • Math.round(max_speed / Math.round(game_speed))



        • Also random gaps



      • if(Math.round(frameCount * game.speed) % max_speed === 0)



        • Yeah... not a single pole spawned at all


      For the second and third things I tried (see above), I expected them to work, but there are still spaces. This might be because of JavaScript's way of handling decimal numbers (It sucks at it) or I am just dumb and doing something completely wrong



      edit: here is a link to my code










      share|improve this question
















      I have made a working Flappy Bird game, but the green poles are spawning in a weird way. I have done it like this:



      • frameCount is a p5.js variable counting the frames

      • draw is a p5.js function that will be done every frame

       let game_speed = 1;
      let max_speed = 1000;
      let spawn_rate = Math.round(max_speed / game_speed);
      function draw()
      if(frameCount % spawn_rate === 0)
      generateNewPole();
      game_speed += (game_speed < max_speed / 10)? 0.001 : 0;
      spawn_rate = Math.round(max_speed / game_speed);



      I have tried the following formulas for the spawn_rate :




      • Math.round(max_speed - game_speed)



        • This didn't work even close to good



      • Math.round(max_speed / game_speed)



        • This worked ok, but I have random big gaps everywhere



      • Math.round((max_speed - game_speed) / game_speed)



        • This worked also quite well, except for random gaps here too



      • Math.round((max_speed - game_speed) / (max.speed / game.speed))



        • The poles spawned at a god-speed rate



      • Math.round(max_speed / Math.round(game_speed))



        • Also random gaps



      • if(Math.round(frameCount * game.speed) % max_speed === 0)



        • Yeah... not a single pole spawned at all


      For the second and third things I tried (see above), I expected them to work, but there are still spaces. This might be because of JavaScript's way of handling decimal numbers (It sucks at it) or I am just dumb and doing something completely wrong



      edit: here is a link to my code







      javascript






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 21:20







      FreeRun Life

















      asked Mar 24 at 20:42









      FreeRun LifeFreeRun Life

      11




      11






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Math.round(max_speed / game_speed)


          I can hazard a guess that the big gaps you describe are caused by Math.round when it switches from rounding down to rounding up (and vice versa). I suspect you'd get more consistant behaviour if you switched to Math.floor or Math.ceil.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328382%2fflappy-bird-is-there-a-way-to-find-the-spawn-rate-of-the-poles%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Math.round(max_speed / game_speed)


            I can hazard a guess that the big gaps you describe are caused by Math.round when it switches from rounding down to rounding up (and vice versa). I suspect you'd get more consistant behaviour if you switched to Math.floor or Math.ceil.






            share|improve this answer



























              0














              Math.round(max_speed / game_speed)


              I can hazard a guess that the big gaps you describe are caused by Math.round when it switches from rounding down to rounding up (and vice versa). I suspect you'd get more consistant behaviour if you switched to Math.floor or Math.ceil.






              share|improve this answer

























                0












                0








                0







                Math.round(max_speed / game_speed)


                I can hazard a guess that the big gaps you describe are caused by Math.round when it switches from rounding down to rounding up (and vice versa). I suspect you'd get more consistant behaviour if you switched to Math.floor or Math.ceil.






                share|improve this answer













                Math.round(max_speed / game_speed)


                I can hazard a guess that the big gaps you describe are caused by Math.round when it switches from rounding down to rounding up (and vice versa). I suspect you'd get more consistant behaviour if you switched to Math.floor or Math.ceil.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 24 at 21:00









                ScootsScoots

                2,20711428




                2,20711428





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328382%2fflappy-bird-is-there-a-way-to-find-the-spawn-rate-of-the-poles%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

                    밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

                    1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴