Basic skymap prototype
This commit is contained in:
parent
66cc4fcb5f
commit
06a6b1b029
6 changed files with 72 additions and 7 deletions
|
@ -98,7 +98,7 @@ set(SOURCES
|
||||||
src/levels.hpp
|
src/levels.hpp
|
||||||
src/sprites/tiling/tilemap.cpp
|
src/sprites/tiling/tilemap.cpp
|
||||||
src/sprites/tiling/tilemap.hpp
|
src/sprites/tiling/tilemap.hpp
|
||||||
src/sprites/tiling/tilemap_config.hpp src/sprites/tiling/tileset_config.hpp src/sprites/tiling/tileset.cpp src/sprites/tiling/tileset.hpp src/game/frame_counter.cpp src/game/frame_counter.hpp)
|
src/sprites/tiling/tilemap_config.hpp src/sprites/tiling/tileset_config.hpp src/sprites/tiling/tileset.cpp src/sprites/tiling/tileset.hpp src/game/frame_counter.cpp src/game/frame_counter.hpp src/game/level/level_renderer.cpp src/game/level/level_renderer.hpp src/sprites/skymap/skymap.cpp src/sprites/skymap/skymap.hpp)
|
||||||
|
|
||||||
set(PHYSICS_00_SOURCES
|
set(PHYSICS_00_SOURCES
|
||||||
src/prototypes/physics_00.cpp)
|
src/prototypes/physics_00.cpp)
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include "../collectables/collectable_factory.hpp"
|
#include "../collectables/collectable_factory.hpp"
|
||||||
#include "../player/player_collection.hpp"
|
#include "../player/player_collection.hpp"
|
||||||
#include "../physics/hole/hole_depth_simulation.hpp"
|
#include "../physics/hole/hole_depth_simulation.hpp"
|
||||||
|
#include "level_renderer.hpp"
|
||||||
|
#include "../../sprites/skymap/skymap.hpp"
|
||||||
|
|
||||||
void LevelLoader::loadLevel(const LevelConfig &levelConfig)
|
void LevelLoader::loadLevel(const LevelConfig &levelConfig)
|
||||||
{
|
{
|
||||||
|
@ -19,23 +21,26 @@ void LevelLoader::loadLevel(const LevelConfig &levelConfig)
|
||||||
MapSimulation::getInstance()->resetMap(levelConfig.worldMapSize);
|
MapSimulation::getInstance()->resetMap(levelConfig.worldMapSize);
|
||||||
PlayerCollection::getInstance()->clear();
|
PlayerCollection::getInstance()->clear();
|
||||||
|
|
||||||
// Add basic game objects
|
// Add rendered level objects
|
||||||
game->addGameObject(SpriteFactory::createTileMap(levelConfig.tileMapConfig));
|
std::shared_ptr<LevelRenderer> levelRenderer = std::make_shared<LevelRenderer>();
|
||||||
|
game->addGameObject(levelRenderer);
|
||||||
|
|
||||||
|
levelRenderer->addChild(std::make_shared<Skymap>());
|
||||||
|
levelRenderer->addChild(SpriteFactory::createTileMap(levelConfig.tileMapConfig));
|
||||||
|
|
||||||
if (DB_WORLD_GRID_RENDER)
|
if (DB_WORLD_GRID_RENDER)
|
||||||
{
|
{
|
||||||
game->addGameObject(std::make_shared<GridDebugLayer>(0, 50, 0, 50));
|
levelRenderer->addChild(std::make_shared<GridDebugLayer>(0, 50, 0, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
game->addGameObject(std::make_shared<TrackingView>());
|
levelRenderer->addChild(PlayerCollection::getInstance());
|
||||||
game->addGameObject(PlayerCollection::getInstance());
|
|
||||||
PlayerCollection::getInstance()->setSpawnPoints(levelConfig.playerSpawnPoints);
|
PlayerCollection::getInstance()->setSpawnPoints(levelConfig.playerSpawnPoints);
|
||||||
|
|
||||||
// Prepare collectables framework
|
// Prepare collectables framework
|
||||||
auto maxDepth = (int) levelConfig.worldMapSize.x * 2;
|
auto maxDepth = (int) levelConfig.worldMapSize.x * 2;
|
||||||
auto collectablesCollection = CollectablesCollection::getInstance();
|
auto collectablesCollection = CollectablesCollection::getInstance();
|
||||||
collectablesCollection->createEmpty(maxDepth);
|
collectablesCollection->createEmpty(maxDepth);
|
||||||
game->addGameObject(collectablesCollection);
|
levelRenderer->addChild(collectablesCollection);
|
||||||
|
|
||||||
// Spawn collectibles
|
// Spawn collectibles
|
||||||
for (auto const &collectableInfo: levelConfig.collectables)
|
for (auto const &collectableInfo: levelConfig.collectables)
|
||||||
|
@ -43,9 +48,14 @@ void LevelLoader::loadLevel(const LevelConfig &levelConfig)
|
||||||
spawnCollectable(collectableInfo);
|
spawnCollectable(collectableInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add physics simulations
|
// Add physics simulations
|
||||||
game->addGameObject(MapSimulation::getInstance());
|
game->addGameObject(MapSimulation::getInstance());
|
||||||
|
|
||||||
|
// Add views
|
||||||
|
game->addGameObject(std::make_shared<TrackingView>());
|
||||||
|
|
||||||
LOG(INFO) << "Finished loading level '" << levelConfig.name << "'.";
|
LOG(INFO) << "Finished loading level '" << levelConfig.name << "'.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
src/game/level/level_renderer.cpp
Normal file
1
src/game/level/level_renderer.cpp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "level_renderer.hpp"
|
12
src/game/level/level_renderer.hpp
Normal file
12
src/game/level/level_renderer.hpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef HOLESOME_LEVEL_RENDERER_HPP
|
||||||
|
#define HOLESOME_LEVEL_RENDERER_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include "../game_object.h"
|
||||||
|
|
||||||
|
class LevelRenderer : public GameObject
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //HOLESOME_LEVEL_RENDERER_HPP
|
28
src/sprites/skymap/skymap.cpp
Normal file
28
src/sprites/skymap/skymap.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include <SFML/Graphics/VertexArray.hpp>
|
||||||
|
#include "skymap.hpp"
|
||||||
|
|
||||||
|
void Skymap::draw(sf::RenderWindow *window)
|
||||||
|
{
|
||||||
|
float mapHeight = 1000;
|
||||||
|
|
||||||
|
sf::VertexArray backgroundGradient(sf::Quads, 4);
|
||||||
|
|
||||||
|
// Defining the coordinates clockwise
|
||||||
|
// Top Left
|
||||||
|
backgroundGradient[0].position = sf::Vector2f(-2 * mapHeight, -2 * mapHeight);
|
||||||
|
backgroundGradient[0].color = sf::Color(150, 200, 255);
|
||||||
|
|
||||||
|
// Top Right
|
||||||
|
backgroundGradient[1].position = sf::Vector2f(2 * mapHeight, -2 * mapHeight);
|
||||||
|
backgroundGradient[1].color = sf::Color(150, 200, 255);
|
||||||
|
|
||||||
|
// Bottom Right
|
||||||
|
backgroundGradient[2].position = sf::Vector2f(2 * mapHeight, mapHeight);
|
||||||
|
backgroundGradient[2].color = sf::Color::White;
|
||||||
|
|
||||||
|
// Bottom Left
|
||||||
|
backgroundGradient[3].position = sf::Vector2f(-2 * mapHeight, mapHeight);
|
||||||
|
backgroundGradient[3].color = sf::Color::White;
|
||||||
|
|
||||||
|
window->draw(backgroundGradient);
|
||||||
|
}
|
14
src/sprites/skymap/skymap.hpp
Normal file
14
src/sprites/skymap/skymap.hpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef HOLESOME_SKYMAP_HPP
|
||||||
|
#define HOLESOME_SKYMAP_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include "../../game/game_object.h"
|
||||||
|
|
||||||
|
class Skymap : public GameObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void draw(sf::RenderWindow *window) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //HOLESOME_SKYMAP_HPP
|
Loading…
Reference in a new issue