Code

This document outlines the integration of legacy GLEED2D code into the oglr project.

Legacy GLEED2D Integration

The oglr project incorporates elements from the previous GLEED2D project, particularly in the area of map loading and tile-based rendering.

1. src/main.cpp

This file is the entry point for the application and demonstrates the integration of GLEED2D code. It includes:

  • main() function: initializes the application, loads a map from a file (presumably a GLEED2D map file), and starts the rendering loop.
  • loadLevel function: utilizes the GLEED2D library to load a map from a file and creates a Level object. The function creates tile entities and sprite entities from the loaded map data.

Example:

// src/main.cpp
          
          Level *level = loadLevel("path/to/map.xml");
          
          // ...
          

Source:

2. src/Level.cpp

  • The Level class represents a game level loaded from a map file.
  • It contains methods for managing and rendering tiles, sprite entities, and other game objects.
  • The Level constructor utilizes data loaded from the GLEED2D map file to initialize the level.

Example:

// src/Level.cpp
          
          // Constructor for the Level class, which takes data from the GLEED2D map file. 
          Level::Level(const std::string &mapPath, const std::string &pathToSpriteSheet) {
            // Load the map data from the file using the GLEED2D library
            loadMapData(mapPath);
          
            // ...
          }
          
          // Function to load the map data
          void Level::loadMapData(const std::string &mapPath) {
            // Load map data from the file using the GLEED2D library
            // ...
          }
          

Source:

3. src/Tile.cpp

  • The Tile class represents a single tile in a level.
  • It contains information about the tile’s texture, position, and other relevant properties.

Example:

// src/Tile.cpp
          
          Tile::Tile(glm::vec2 position, int textureId) : m_position(position), m_textureId(textureId) {
            // Initialize tile properties.
            // ...
          }
          
          void Tile::render() {
            // Render the tile using the appropriate texture and position.
            // ...
          }
          

Source:

4. src/SpriteEntity.cpp

  • The SpriteEntity class represents a sprite entity within a level.
  • It manages the sprite’s texture, animation, position, and other relevant properties.

Example:

// src/SpriteEntity.cpp
          
          SpriteEntity::SpriteEntity(glm::vec2 position, int textureId, int animationId) :
            m_position(position), m_textureId(textureId), m_animationId(animationId) {
            // Initialize sprite properties.
            // ...
          }
          
          void SpriteEntity::render() {
            // Render the sprite using the appropriate texture, animation, and position.
            // ...
          }
          

Source:

5. src/gleed/

  • The gleed/ directory contains code specific to the GLEED2D library.
  • This code handles loading and parsing map files created using GLEED2D.
  • It likely includes classes like Map, Layer, Object, etc., which are used to represent the map data and its elements.

Example:

  • This directory might contain files like MapLoader.cpp, Layer.cpp, Object.cpp, etc., which are specific to the GLEED2D library.

Source:

Integration:

The integration of GLEED2D code primarily revolves around the Level class and its dependencies. The Level class loads a map file from a specified path, extracting tile data, sprite data, and potentially other relevant information. This data is then used to create tile and sprite entities, which are managed and rendered by the Level class.

Note: The integration with GLEED2D is based on the assumptions about the library’s functionality and the format of its map files. If modifications are made to either GLEED2D or the map format, the integration code might require adjustments.