<tfoot id='ntnMp'></tfoot>

        <bdo id='ntnMp'></bdo><ul id='ntnMp'></ul>
    1. <legend id='ntnMp'><style id='ntnMp'><dir id='ntnMp'><q id='ntnMp'></q></dir></style></legend>
    2. <i id='ntnMp'><tr id='ntnMp'><dt id='ntnMp'><q id='ntnMp'><span id='ntnMp'><b id='ntnMp'><form id='ntnMp'><ins id='ntnMp'></ins><ul id='ntnMp'></ul><sub id='ntnMp'></sub></form><legend id='ntnMp'></legend><bdo id='ntnMp'><pre id='ntnMp'><center id='ntnMp'></center></pre></bdo></b><th id='ntnMp'></th></span></q></dt></tr></i><div id='ntnMp'><tfoot id='ntnMp'></tfoot><dl id='ntnMp'><fieldset id='ntnMp'></fieldset></dl></div>
      1. <small id='ntnMp'></small><noframes id='ntnMp'>

        俄罗斯方块计时问题

        时间:2024-08-11

          <bdo id='D2DIh'></bdo><ul id='D2DIh'></ul>

                <tbody id='D2DIh'></tbody>
              <tfoot id='D2DIh'></tfoot>

              1. <i id='D2DIh'><tr id='D2DIh'><dt id='D2DIh'><q id='D2DIh'><span id='D2DIh'><b id='D2DIh'><form id='D2DIh'><ins id='D2DIh'></ins><ul id='D2DIh'></ul><sub id='D2DIh'></sub></form><legend id='D2DIh'></legend><bdo id='D2DIh'><pre id='D2DIh'><center id='D2DIh'></center></pre></bdo></b><th id='D2DIh'></th></span></q></dt></tr></i><div id='D2DIh'><tfoot id='D2DIh'></tfoot><dl id='D2DIh'><fieldset id='D2DIh'></fieldset></dl></div>

                  <small id='D2DIh'></small><noframes id='D2DIh'>

                  <legend id='D2DIh'><style id='D2DIh'><dir id='D2DIh'><q id='D2DIh'></q></dir></style></legend>
                  本文介绍了俄罗斯方块计时问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在用PyGame编写俄罗斯方块程序,遇到了一个有趣的问题。

                  在我提出问题之前,以下是伪代码:

                  while True:
                      # In this part, the human controls the block to go left, right, or speed down
                      if a key is pressed and the block isnt touching the floor:
                          if the key is K-left:
                              move piece left one step
                          if the key is K-right:
                              move piece right one step
                          if the key is K-down:
                              move piece down one step
                  
                  
                      # This part of the code makes the piece fall by itself
                      if the block isnt touching the floor:
                          move block down one step
                  
                      # This part makes the while loop wait 0.4 seconds so that the block does not move
                      # down so quickly
                      wait 0.4 seconds
                  

                  问题在于,由于代码的"等待0.4秒"部分,人工控件只能每0.4秒移动一次。我希望它能让挡路以人能按下的速度移动,同时挡路每0.4秒就掉一次。我如何安排代码才能做到这一点呢?谢谢!

                  推荐答案

                  我在这里看到的主要问题是您使用0.4秒的等待来限制帧速率。

                  您不应该限制帧率,而应该限制您的挡路的下落速度。

                  如果我没记错的话,有一个公式可以用来做到这一点。它是基于自上一帧以来经过的时间长度。它看起来像:

                  fraction of a second elapsed since last frame * distance you want your block to move in a second
                  

                  这样,您可以保持您的主循环完好无损,并且移动处理将在每一帧进行。

                  这篇关于俄罗斯方块计时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python:如何序列化多人游戏的对象? 下一篇:在游戏“外星人入侵”中,为什么我的外星人只出现了一排?

                  相关文章

                    <bdo id='OmjdD'></bdo><ul id='OmjdD'></ul>
                  1. <i id='OmjdD'><tr id='OmjdD'><dt id='OmjdD'><q id='OmjdD'><span id='OmjdD'><b id='OmjdD'><form id='OmjdD'><ins id='OmjdD'></ins><ul id='OmjdD'></ul><sub id='OmjdD'></sub></form><legend id='OmjdD'></legend><bdo id='OmjdD'><pre id='OmjdD'><center id='OmjdD'></center></pre></bdo></b><th id='OmjdD'></th></span></q></dt></tr></i><div id='OmjdD'><tfoot id='OmjdD'></tfoot><dl id='OmjdD'><fieldset id='OmjdD'></fieldset></dl></div>
                  2. <tfoot id='OmjdD'></tfoot>
                    <legend id='OmjdD'><style id='OmjdD'><dir id='OmjdD'><q id='OmjdD'></q></dir></style></legend>

                    <small id='OmjdD'></small><noframes id='OmjdD'>