Sunday, April 1, 2018

RPG: Terrain & Canopies

Lots of work has been completed on the RPG recently, so I'm trying to catch up on development posts now.

The game had all the terrain types hard coded. To get any kind of new terrain to show required creating the textures, adding new variables, calling functions to load those variables, and adding in switch cases to know where to load those textures. Took way too long.

The new method has a single text file that points to all the terrain types available.


The game loading function goes through each line of that file to parse the corresponding dat file for a specific terrain type.


Oceans happen to have 4 animated frames to give the illusion of waves. There are additional sprites for the ocean depending on how it borders neighboring textures (corners and sides). Those additional sprites are drawn when necessary to avoid hard edges for terrain such as water or grass.

The second line of the Ocean.dat has "o" - which is the code for this terrain type. The game's TerrainMap file is a 360x180 matrix of code letters that determine how the world looks.


There are so many unique variables a single block of terrain needs, I will inevitable go to a binary format. But for now just a large ASCII map is convenient.

In addition to the externalized terrain types, I've added a new concept called "canopies". Canopies are overlaid above the terrain to mimic things such as building roofs, but they don't block character movement.


Loading of canopies is handled very similar to terrain. There is a list of the canopy types.


And folders of each canopy type that contain a dat file and texture.


And finally the canopy map.


So although not much to look at now, these major changes allow me to greatly accelerate development.

The next post will be a significant one though! I've got a control scheme pretty well worked out and am in the process of implementing skills / spells.

No comments:

Post a Comment