久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='pgQPu'></bdo><ul id='pgQPu'></ul>

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

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

        Python只運行一次while循環

        Python only running while loop once(Python只運行一次while循環)
          <legend id='kYTlL'><style id='kYTlL'><dir id='kYTlL'><q id='kYTlL'></q></dir></style></legend>
          1. <small id='kYTlL'></small><noframes id='kYTlL'>

            <i id='kYTlL'><tr id='kYTlL'><dt id='kYTlL'><q id='kYTlL'><span id='kYTlL'><b id='kYTlL'><form id='kYTlL'><ins id='kYTlL'></ins><ul id='kYTlL'></ul><sub id='kYTlL'></sub></form><legend id='kYTlL'></legend><bdo id='kYTlL'><pre id='kYTlL'><center id='kYTlL'></center></pre></bdo></b><th id='kYTlL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='kYTlL'><tfoot id='kYTlL'></tfoot><dl id='kYTlL'><fieldset id='kYTlL'></fieldset></dl></div>
                <tbody id='kYTlL'></tbody>
              • <bdo id='kYTlL'></bdo><ul id='kYTlL'></ul>

                • <tfoot id='kYTlL'></tfoot>
                  本文介紹了Python只運行一次while循環的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  import pygame
                  
                  r_colour = (200, 100,100)
                  bg_colour = (0,175,200)
                  (width, height) = (600, 600)
                  
                  screen = pygame.display.set_mode((width, height))
                  screen.fill(bg_colour)
                  pygame.draw.rect(screen, r_colour, (30, 30, 100, 100), 0)
                  
                  pygame.display.flip()
                  
                  running = True
                  while True:
                      for event in pygame.event.get():
                          if event.type == pygame.KEYDOWN:
                              if event.key == pygame.K_s:
                                  screen.fill(bg_colour)
                                  pygame.draw.rect(screen, r_colour, (20, 30, 100, 100), 0)
                                  pygame.display.update()
                  
                  
                  if running == True:
                        for event in pygame.event.get():
                            if event.type == pygame.KEYDOWN:
                                  if event.key == pygame.K_s:
                                      screen.fill(bg_colour)
                                      pygame.draw.rect(screen, r_colour, (20, 30, 100, 100), 0)
                                      pygame.display.update()
                  
                  
                  
                  while running:
                    for event in pygame.event.get():
                      if event.type == pygame.QUIT:
                        break
                        running = False
                  
                  
                  
                  pygame.quit()
                  

                  我試圖讓紅色方塊在按下s"鍵時移動,不知道為什么它只移動一次然后停止.對編程非常陌生,所以很抱歉,如果它很長或難以閱讀.

                  I am trying to get the red square to move when pressing the 's' key, not sure as to why it only moves once and then stops. Very new to programming, so I am sorry, if it's long or hard to read.

                  推薦答案

                  一個典型的應用程序有 1 個單一的應用程序循環.應用程序循環:

                  A typical application has 1 single application loop. The application loop does:

                  • 處理事件并根據事件更改狀態
                  • 清除顯示
                  • 繪制場景
                  • 更新顯示

                  KEYDOWY 事件在按下某個鍵時發生一次,但在按住某個鍵時不會連續發生.
                  對于連續運動,您可以通過 <代碼>pygame.key.get_pressed():

                  The KEYDOWY event occurs once when a key is pressed, but it does not occur continuously when a key is hold down.
                  For a continuously movement you can get the state of the keys by pygame.key.get_pressed():

                  keys = pygame.key.get_pressed()
                  

                  例如如果 s 的狀態被按下,可以通過 keys[pygame.K_s] 來評估.

                  e.g. If the state of s is pressed can be evaluated by keys[pygame.K_s].

                  為矩形的位置添加坐標(x, y).當按鍵被按下時,在主應用程序循環中不斷地操作位置.

                  Add coordinates (x, y) for the position of the rectangle. Continuously manipulate the position in the main application loop, when a key is pressed.

                  例如
                  如果按下 d,則增加 x,如果按下 a,則減少 x.
                  如果按下 s,則增加 y,如果按下 w,則減少 y:

                  e.g.
                  Increment x if d is pressed and decrement x if a is pressed.
                  Increment y if s is pressed and decrement y if w is pressed:

                  import pygame
                  
                  r_colour = (200, 100,100)
                  bg_colour = (0,175,200)
                  (width, height) = (600, 600)
                  x, y = 20, 30
                  
                  screen = pygame.display.set_mode((width, height))
                  
                  running = True
                  while running:
                  
                      # handle the events
                      for event in pygame.event.get():
                          if event.type == pygame.QUIT:
                              running = False
                  
                      # change coordinates
                      keys = pygame.key.get_pressed()
                      if keys[pygame.K_d]:
                          x += 1
                      if keys[pygame.K_a]:
                          x -= 1
                      if keys[pygame.K_s]:
                          y += 1
                      if keys[pygame.K_w]:
                          y -= 1
                  
                      # clear the display
                      screen.fill(bg_colour)
                      # draw the scene
                      pygame.draw.rect(screen, r_colour, (x, y, 100, 100), 0)
                      # update the display
                      pygame.display.update()
                  
                  pygame.quit()
                  

                  這篇關于Python只運行一次while循環的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

                  <legend id='si5Mn'><style id='si5Mn'><dir id='si5Mn'><q id='si5Mn'></q></dir></style></legend>
                    <tbody id='si5Mn'></tbody>

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

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

                            主站蜘蛛池模板: 中文字幕亚洲欧美日韩在线不卡 | 欧美日一区二区 | 国产亚洲一区二区精品 | 91精产国品一二三区 | 日韩高清成人 | 亚洲 中文 欧美 日韩 在线观看 | 日韩精品免费在线 | 国产在线第一页 | 亚洲视频网| 久久av一区| 罗宾被扒开腿做同人网站 | 国产亚洲成av人片在线观看桃 | 国产伦精品一区二区三区高清 | 韩国精品一区 | 91在线播 | 亚洲 欧美 日韩在线 | 欧美一级黄色网 | 久在线 | 91久久国产综合久久91精品网站 | 天堂亚洲网 | 亚洲午夜精品一区二区三区他趣 | a级片在线观看 | 亚洲精品国产一区 | 精品欧美色视频网站在线观看 | 美女一区| 日韩a级片| 国产成人小视频 | 精品国产乱码久久久久久蜜臀 | 成人精品一区二区三区 | 日韩一级免费电影 | 麻豆毛片 | 日韩av一区二区在线观看 | av在线免费观看网站 | 黄网站免费在线 | 国产精品久久二区 | 国产免费麻豆视频 | 91免费观看在线 | 国产精品毛片一区二区在线看 | 99国产精品视频免费观看一公开 | 国产乱码精品一品二品 | 在线观看欧美日韩视频 |