我可以用两种不同的颜色制作 Pygame 矩形轮廓吗?

问题描述 投票:0回答:1

我想用油漆制作的矩形图像

if(blueBoxX!=redBoxX or blueBoxY!=redBoxY):
    pygame.draw.rect(scrn, (0, 100, 255), (blueBoxX*75, blueBoxY*75, 75, 75), 3)
    pygame.draw.rect(scrn, (255, 100, 0), (redBoxX*75, redBoxY*75, 75, 75), 3)
else:
    "when they collide I want it to show by showing two colors at one spot"

我正在考虑仅使用 pygame.draw.line 的直线,但想知道 pygame.draw.rect 是否是可能的选项

python python-3.x pygame
1个回答
0
投票

不。

pygame.draw.rect()
只有一种颜色,并且无法选择仅绘制轮廓的某些部分或侧面。我建议使用
pygame.draw.lines()
:

l1 = [(x*75, y*75 + 75), (x*75, y*75), (x*75 + 75, y*75)]
pygame.draw.lines(scrn, (0, 100, 255), False, l1, 3)
l2 = [(x*75, y*75 + 75), (x*75 + 75, y*75 + 75), (x*75 + 75, y*75)]
pygame.draw.lines(scrn, (255, 100, 0), False, l2, 3)
© www.soinside.com 2019 - 2024. All rights reserved.