draw.lineメソッドでウィンドウに直線を描画する。
import pygame
from pygame.locals import *
import sys
BLACK = (0, 0, 0)
WHITE = (255,255,255)
size = (640, 480)
width, height = size
board_w, board_h = 450, 450
space_w, space_h = (width-board_w)/2, (height-board_h)/2
pygame.init()
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Maze")
while True:
screen.fill(BLACK)
pygame.draw.rect(screen,WHITE,(space_w,space_h,board_w,board_h),1)
for y in range(1, 3):
pygame.draw.line(screen,WHITE,(space_w,y*(board_h/3)+space_h),(width-space_w-1,y*(board_h/3)+space_h))
for x in range(1, 3):
pygame.draw.line(screen,WHITE,(x*(board_w/3)+space_w,space_h),(x*(board_w/3)+space_w,height-space_h-1))
pygame.display.update()
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
参考
draw - Pygameドキュメント 日本語訳