PyGame, I guess.
I want to be able to see what the rooms look like, so I guess it’s time to bring in PyGame and get something displaying on the screen. I plan to cheat. Good result!
No, wait, it’s not cheating, it’s re-use! I’m going to look at some of my other pygame programs and re-use, that’s it, re-use some of the code. It’s like research only even better.
In practically no time, I have this new main program:
import pygame
screen_width = 1024
screen_height = 1024 - 128
cell_size = 16
class DungeonView:
def __init__(self):
pygame.init()
pygame.display.set_caption("Dungeon")
self.screen = pygame.display.set_mode(
(screen_width, screen_height))
self.clock = pygame.time.Clock()
def main_loop(self):
running = True
moving = False
background = "gray33"
color = "darkblue"
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
self.screen.fill(background)
for x in range(screen_width//cell_size):
dx = (x+1)*cell_size
for y in range(screen_height//cell_size):
dy = (y+1)*cell_size
pygame.draw.line(
self.screen, color,
(dx, 0),
(dx, screen_height))
pygame.draw.line(
self.screen, color,
(0, dy),
(screen_width, dy)
)
self.clock.tick(60)
pygame.display.flip()
pygame.quit()
That draws a grid that isn’t too awful to look at. (The first one I drew was horrid.)

We’re drawing the grid 60 times a second, which is plenty, given that it doesn’t ever change.
This will do for now.
Summary
Re-using code from another program gave me a good start for my grid, and once that was in place, drawing a few lines was easy. When we come to drawing rooms, I expect it’ll be little more than iterate the rooms and for each set of coordinates in the room, draw a rectangle at that location in the room’s color (which we’ll assign in some clever way that I have stolen learned from GeePaw Hill). Then we’ll be able to visualize the dungeon layout quite nicely.
So far so good. See you next time!