0
我想製作一個摩天輪動畫(在面向對象的編程實踐中),但我正在努力讓車輪繞着車輪。摩天輪動畫(使東西在一個圓圈內移動)python
#ferris wheel(circle)
pygame.draw.circle(screen, blue, [250,250],150, 8)
#carriage
pygame.draw.polygon(screen, yellow, [[220+cx,385+cy],[280+cx,385+cy],[270+cx,400+cy],[230+cx,400+cy]],0)
def carriagemovement(top,bottom):
global cx
global cy
top = 0
bottom = 1
if bottom == 1:
if cx == 0 or cx < 80:
cx = cx + 4
cy = cy - 1
print(cx)
else:
if bottom == 1:
if cx == 80 or (cx > 80 and cx < 148):
cx = cx + 4
cy = cy - 3
print (cx)
else:
if bottom ==1:
if cx == 148 or (cx > 148 and cx < 159):
cx = cx + 0.5
cy = cy - 3
print (cx)
else:
top = 1
bottom = 0
if top == 1:
if (cx == 159 and top == 1) or (cx < 159 and top == 1):
cx = cx - 0.5
cy = cy - 3
print (cx)
的carriagemovement()是目前我做的方式(但它熄滅了一圈,由於if語句,當我固定的(使用頂部和底部),它只是停止短)。
有沒有我不使用的功能或方法會使它更容易?有另一種方法嗎?
謝謝!
謝謝,這更有意義!但你能舉個例子嗎?我還沒有完成極座標 – 2014-10-04 08:06:49