0
我正在製作一個自上而下的生存遊戲。我的碰撞問題:pygame碰撞y軸不工作
我正在讓玩家與長椅碰撞,問題是x軸碰撞有效,但y軸碰撞甚至沒有發現。
if playerx + playerw > 268 and playerx < 368 and playery + playerh > 392 and playery < 442:
if playerx + playerw > 268 and playerx + playerw < 275:
playerx -= 5
if playerx > 360 and playerx < 368:
playerx += 5
if playery > 430 and playery < 441:
playery += 5
if playery + playerh > 386 and playery + playerh < 392:
playery -= 5
代碼是顯而易見的,PlayerX的玩家= COORDS X ,, playery =遊戲者Y COORDS ,, playerw =玩家寬度,, playerh =玩家ħ,, 268,368,392,和442是替補左上角和右下角的座標。
同樣,我可以在左邊和右邊碰撞,但不會上升或下降,任何解決方案?
編輯:
它固定半葉,下,左,右碰撞工作,而不是頂部。
就是這樣,謝謝你的朋友! – HKVariant 2014-12-04 02:08:44