Work Samples
CV
About Me
Email Me!

Portfolio | Stefan Andersson

Work Samples
CV
About Me
Email Me!
Building Tool

Building Tool

Internally, the grid is constructed using a simple one-dimensional array, with each element representing one corner of a grid tile.

Externally, a large mesh is generated and every tile on the grid is given five vertices; four corners and one center.

A spritesheet is used as the texture for the mesh and the UVs of each tile are changed in runtime The center UV is only used to help smooth out the lighting.

The build tool snaps to the internal grid - so, the corners of the rendered tiles - and changes the UVs of the mesh in the selected location, thus changing the part of the sprite sheet that is displayed to the user.

The build tool also supports adding doors and airlocks to existing walls, and these will also animate when a character wants to pass through.

Originally, there was support for diagonal walls as well, but as I learned the hard way, there’s a reason most grid-based games don’t attempt diagonal walls. Removing this feature greatly simplified the code base!

Coloring Tool

Coloring Tool

The painting tool allows the player to create a custom color scheme for tiles to use, then apply it to whatever tiles they choose.

A texture based on the main spritesheet is used to define the cardinal directions (and special components) of the displayed environment. The user can pick 1/128 colors per direction and special components and when paint is applied, the color indices are sent to the GPU via the tile UVs. The frag shader then checks the texture and applies the appropriate color for the appropriate part of the sprite.

Lighting Tool

Lighting Tool

The lighting system allows the player to place colored lights on the grid. 

Like the other tools, the lighting system simply deposits a color and brightness value onto the tiles of the grid mesh and the shader decodes the information to render it nicely. To get the light to move around corners nicely, I simply use A* pathfinding from the light source to every tile in its range and base the brightness value off the distance of the found path.

1 2 3
Previous Next
Building Tool
Coloring Tool
Lighting Tool
Back to Top
stf.andersson@gmail.com