I’m creating a grid based program using Python and the openGL graphics framework called pyglet. In this program the grid is going to be the foundation for more complex logic with the implementation of the A*(star) search algorithm. More on that later though. Today I just had to build the grid.
- dynamic width, height and cell size
- return individual cell coordinates based on mouse coordinates
- cell adjacency logic to return all cells adjacent to a selected cell
- cell subset extrapolation
Essentially the Grid is a model that stores the basic information about the grid and supplies some methods for fetching individual cells and groups of cells based on supplied parameters. The Grid itself doesn’t actually render anything to the screen. To take care of this I’ve built a object called GridRenderer.
- display grid
- allow user to paint and erase cells into the grid
- clear grid
- display subsets ( selected & adjacent for now ) of cells in unique colors
Source code and video examples are on the way…
Below are some screen grabs of the progress so far: