import pygame
import sys
from pygame.locals import *
pygame.init()
width, height = 800, 600
screen = pygame.display.set_mode((width, height), 0, 32)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
screen.fill(WHITE)
vertices = [
(100, 100, 100), # 点1 (左上角)
(200, 100, 100), # 点2 (右上角)
(200, 200, 100), # 点3 (右下角)
(100, 200, 100), # 点4 (左下角)
(150, 150, 200) # 点5 (顶部中间)
]
pygame.draw.line(screen, BLUE, vertices[0], vertices[1], 5) # AB边
pygame.draw.line(screen, BLUE, vertices[1], vertices[2], 5) # BC边
pygame.draw.line(screen, BLUE, vertices[2], vertices[3], 5) # CD边
pygame.draw.line(screen, BLUE, vertices[3], vertices[0], 5) # DA边
pygame.draw.line(screen, RED, vertices[4], vertices[1], 5) # A到顶部点5的线
pygame.draw.line(screen, RED, vertices[4], vertices[2], 5) # B到顶部点5的线
pygame.draw.line(screen, RED, vertices[4], vertices[3], 5) # C到顶部点5的线
pygame.draw.line(screen, RED, vertices[4], vertices[0], 5) # D到顶部点5的线
pygame.draw.circle(screen, GREEN, vertices[4], 10) # 绘制顶部点5(可以看作是立方体的一个顶点)