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

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해