第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

替換“if 語句條件”

替換“if 語句條件”

Helenr 2023-04-11 16:00:18
def move_dot(window, center, radius, velocity):    size = (window.get_width(), window.get_height())    for index in range(0, 2):        # update center at coordinate        center[index] = center[index] + velocity[index]        # dot edge outside window?        if (center[index] <= radius) or (center[index] + radius >= size[index]):        # change direction            velocity[index] = - velocity[index]這是我上面的代碼,用于在窗口內(nèi)彈跳的程序。我的問題是我只用什么來替換if (center[index] <= radius) or (center[index] + radius >= size[index]):線,以便它的中心接觸窗口邊緣而不是在其邊緣之一接觸窗口邊緣時(shí)彈跳。(我將在下面附上完整的問題,以便任何人更好地理解我正在嘗試做的事情。[如果您希望點(diǎn)在其中心接觸窗口邊緣時(shí)彈跳而不是在其邊緣之一接觸窗口邊緣時(shí)彈跳,應(yīng)該用什么代碼替換“if 語句條件”?你只能改變條件。您不能添加或刪除任何其他代碼。]我嘗試使用代碼if (center[index] <= 0) or (center[index] + radius >= size(window(500,400))):&if (center[index] <= 0) or (center[index] + radius >= size[window]):我會(huì)得到錯(cuò)誤Incorrect: It should bounce when either coordinate of the center is less than or equal to 0 or larger than or equal to the size (width or height) of the window.。有人可以指導(dǎo)我或幫助我嗎?謝謝
查看完整描述

1 回答

?
湖上湖

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊

基本上,您希望球在球中心碰到窗邊時(shí)反彈。它目前被編碼為在球邊緣擊中時(shí)反彈。

檢查球位置時(shí)只需刪除半徑間隙:

if (center[index] <= 0) or (center[index] >= size[index]):


查看完整回答
反對(duì) 回復(fù) 2023-04-11
  • 1 回答
  • 0 關(guān)注
  • 100 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)