Skip to content

mklauber/pygame-hex-grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HexMap

A HexGrid implementation for PyGame

Introduction

HexMap is a python module for use on top of pygame. It is designed to take a lot of the work out of utilizing a hexgrid.

Classes

Map( object )

Map.__init__( (rows, cols) )

The Map object manages most of the basic data manipulation and access for the hexMap. You can think of it as the table tracking all the positioning information regarding your grid. It is capable of telling you the distance between two cells, the direction from one cell to another, and all the valid cells in a variety of shapes.

valid cells are cells which are present on this map

A Map is numbered as Follows:

___     ___     ___

/0,0___/1,2___/2,4 ___/1,1___/2,3___/ /1,0___/2,2___/3,4___/2,1___/3,3___/ /2,0___/3,2___/4,4___/3,1___/4,3___/ /3,0___/4,2___/5,4___/4,1___/5,3___/ /4,0___/5,2___/6,4___/5,1___/6,3___/ ___/ ___/

Map.distance( start, destination )

This method will tell you the straight distance between two cells, ignoring any obstacles in the way.:

Map.direction( start, destination )

This method will tell you the direction from the start point to the destination point.:

Map.neighbors( cell )

This will tell you the valid cells adjoining this cell. does not include the cell itself:

Map.spread( cell, radius=1 )

Returns all the valid cells within radius of cell, including the cell itself.:

Map.cone( cell, direction, length=1 )

This method returns the set of valid cells expanding out from 3 cells facing direction from cell, extending length.

Grid( dict )

Grid.__init__( map )

MapUnit( object )

MapUnit.__init__( grid )

Render( object )

Render.__init__( map, radius=16 )

RenderUnits( Render )

RenderGrid( Render )

RenderFog( Render )

Example

About

A Hex grid implementation for managing units in pygame.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages