7.0.1 - Συναρτήσεις σχεδιασμού

Στην προηγούμενη ενότητα δημιουργήσαμε μία συνάρτηση για να σχεδιάσουμε ένα χιονάνθρωπο. Σε αυτή τη συνάρτηση χρησιμοποιήσαμε μεταβλητές για να σχεδιάσουμε το χιονάνθρωπο σε διαφορετικές θέσεις μέσα στην οθόνη. 

Η Συνάρτηση είχε γραφεί έξω από την κύρια επανάληψη της pygame:

def draw_snowman(screen, x, y): # Draw a circle for the head pygame.draw.circle(screen, WHITE, [60 + x, 50 + y], 15) # Draw the middle snowman circle pygame.draw.circle(screen, WHITE, [60 + x, 80 + y], 20) # Draw the bottom snowman circle pygame.draw.circle(screen, WHITE, [60 + x, 120 + y], 30) # Draw the buttons pygame.draw.circle(screen, BLACK, [60 + x, 120 + y], 6) pygame.draw.circle(screen, RED, [60 + x, 120 + y], 4) pygame.draw.circle(screen, BLACK, [60 + x, 100 + y], 6) pygame.draw.circle(screen, RED, [60 + x, 100 + y], 4) pygame.draw.circle(screen, BLACK, [60 + x, 80 + y], 6) pygame.draw.circle(screen, RED, [60 + x, 80 + y], 4) #Draw the hat pygame.draw.rect(screen, BROWN, [45 + x, 8 + y, 30,30]) pygame.draw.rect(screen, BROWN, [30 + x, 34 + y, 60,5]) #Draw the eyes pygame.draw.circle(screen, BLACK, [54 + x, 44 + y], 3) pygame.draw.circle(screen, BLACK, [66 + x, 44 + y], 3) #Draw the mouth pygame.draw.arc(screen, RED, [50 + x, 40 + y, 20, 20] , 3.34, 6.08,3) #Draw the nose pygame.draw.polygon(screen, ORANGE, [[58 + x , 46 + y], [60 + x , 54 + y], [72 + x, 60 + y]], 0)