Question: I am tasked with making a 4 x 4 pyraminx and ive got column rotations and row rotations. The part i am stuck on is
I am tasked with making a x pyraminx and ive got column rotations and row rotations. The part i am stuck on is my draw function. When I run the code for some reason it leaves gaps in the triangles and doesnt fill them in Please Help code provided below with picture.
def drawtrianglesurface color, points:
pygame.draw.polygonsurface color, points
pygame.draw.polygonsurface BLACK, points,
def drawpyraminxscreen pyraminx:
centerx centery WIDTH HEIGHT
size
# Define the positions of the four faces
positions
centerx centery size # Top
centerx size centery size # Left
centerx size centery size # Right
centerx centery size # Bottom
facelabels Front F 'Left L 'Right R 'Back B
rowkeys QWERASDFZXCV
colkeys TYUIGHJKBNML
font pygame.font.FontNone
for faceindex, face in enumeratepyraminxfaces:
x y positionsfaceindex
# Draw face label
label font.renderfacelabelsfaceindex True, BLACK
screen.blitlabelx label.getwidth y size
# Draw the smaller triangles
smallsize size
for i in range:
for j in range i:
smallx x j i smallsize
smally y i smallsize math.sqrt
smallpoints
smallx smally
smallx smallsize smally smallsize math.sqrt
smallx smallsize smally smallsize math.sqrt
index i i i j
if index lenface:
color COLORMAP.getfaceindex WHITE # Use WHITE as fallback color
drawtrianglescreen color, smallpoints
else:
printfWarning: Invalid index index for face faceindex
# Draw row label
if i lenrowkeysfaceindex:
keylabel font.renderrowkeysfaceindexi True, BLACK
labelx x i smallsize
labely y i smallsize math.sqrt
screen.blitkeylabel, labelx labely
# Draw column labels
for j in range:
if j lencolkeysfaceindex:
keylabel font.rendercolkeysfaceindexj True, BLACK
labelx x j smallsize
labely y smallsize
screen.blitkeylabel, labelx labely
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
