Forgotten Elixir

An enchanting engine where magic and technology intertwine

Initial Level Definitions

created: 2025-03-07 04:34:33 UTC
last updated: 2025-03-07 06:04:21 UTC

Wanted to write this to show off what the level configuration, or definitions, looked like in the C-version. As I am moving the codebase to C++, I will probably bring over the format, but it may also change down the line. 

player:
  x: 100
  y: 100
map:
  rows: 10
  columns: 10
  file: ./assets/maps/one
textures:
  - ./assets/textures/BRICK_3B.PNG
  - ./assets/textures/BRICK_1A.png
  - ./assets/textures/BRICK_2B.png
  - ./assets/textures/light.png
  - ./assets/textures/armor.png
sprites:
  - x: 500
    y: 500
    texture: 3
  - x: 250
    y: 250
    texture: 4

It is rather self explanatory. The basic things needed for a level are defined in the YAML. First, a player's position. This is in "world" coordinates. Followed by some map data. How many columns and rows along with a path to the map file to be read in by the engine. Textures are just a list of file paths. Last are sprites. Sprite are comprised of world coordinates and a texture number that maps to one of the textures above.

Below is what a map file looks like.

1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 3
1 0 0 0 0 0 0 0 0 3
1 0 0 0 0 0 0 0 0 2
1 1 1 1 1 1 3 3 2 2

The map is just a grid made up of numbers that map to a texture or not a texture. '0' meaning that nothing is there. Any number above '0' should be the number for a texture in the array of textures.