Cleaned static variables now part of the maze
This commit is contained in:
parent
24ff555e88
commit
648548693d
3 changed files with 10 additions and 12 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "MovementManager.h"
|
||||
|
||||
Vec3i current_map_colour(const Vec3d& world_pos, const Texture& texture, const int& pixel_scale)
|
||||
Vec3i current_map_colour(const Vec3d& world_pos, const Texture& texture, const unsigned int& pixel_scale)
|
||||
{
|
||||
Vec2i map_pos{static_cast<int>(world_pos.x/pixel_scale),
|
||||
static_cast<int>(world_pos.z/pixel_scale)};
|
||||
|
@ -16,7 +16,7 @@ Vec3i current_map_colour(const Vec3d& world_pos, const Texture& texture, const i
|
|||
texture.image_data[data_index+2]};
|
||||
}
|
||||
|
||||
void constrained_translation(const Vec3d& translation, Camera& camera, const Texture& map, const int& pixel_scale)
|
||||
void constrained_translation(const Vec3d& translation, Camera& camera, const Texture& map, const unsigned int& pixel_scale)
|
||||
{
|
||||
Vec3d original_position = camera.get_eyepos();
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
#include "TileTypes.h"
|
||||
|
||||
/// Returns the colour of the pixel corresponding to the current world position, assuming the map starts at (0,0).
|
||||
Vec3i current_map_colour(const Vec3d& world_pos, const Texture& texture, const int& pixel_scale);
|
||||
Vec3i current_map_colour(const Vec3d& world_pos, const Texture& texture, const unsigned int& pixel_scale);
|
||||
|
||||
/// Translates the camera inside the maze and check for collisions
|
||||
/// \param translation Translation that will be executed in the horizontal plane, x forward, z strafe.
|
||||
void constrained_translation(const Vec3d& translation, Camera& camera, const Texture& map, const int& pixel_scale);
|
||||
void constrained_translation(const Vec3d& translation, Camera& camera, const Texture& map, const unsigned int& pixel_scale);
|
||||
|
||||
#endif //LABYRINTHE_MOVEMENTMANAGER_H
|
||||
|
|
14
src/main.cpp
14
src/main.cpp
|
@ -8,8 +8,6 @@
|
|||
#include "TileTypes.h"
|
||||
#include "Maze.h"
|
||||
|
||||
static int score = 0;
|
||||
|
||||
static Texture ground;
|
||||
static Texture wall;
|
||||
static Texture out;
|
||||
|
@ -19,9 +17,7 @@ static Model3D raptor_model;
|
|||
static Maze* maze;
|
||||
|
||||
static constexpr float horizontal_speed = 0.15;
|
||||
static constexpr int units_per_pixel = 2;
|
||||
static constexpr int map_side = 32;
|
||||
static constexpr int corner_pos = (map_side*units_per_pixel);
|
||||
static int score = 0;
|
||||
|
||||
void manage_inputs()
|
||||
{
|
||||
|
@ -51,9 +47,9 @@ void manage_inputs()
|
|||
translation.x -= horizontal_speed;
|
||||
}
|
||||
|
||||
constrained_translation(translation,OGLE::camera,maze->map,units_per_pixel);
|
||||
constrained_translation(translation,OGLE::camera,maze->map,maze->scaling_factor);
|
||||
|
||||
Vec3i map_colour = current_map_colour(OGLE::camera.get_eyepos(),maze->map, units_per_pixel);
|
||||
Vec3i map_colour = current_map_colour(OGLE::camera.get_eyepos(),maze->map, maze->scaling_factor);
|
||||
if (map_colour == Tiles::end)
|
||||
{
|
||||
std::cout << "Success !" << std::endl;
|
||||
|
@ -99,9 +95,11 @@ int main(int argc, char** argv)
|
|||
raptor_model.set_scaling(0.0025,0.0025,0.0025);
|
||||
raptor_model.set_rotation(-90,1,0,0);
|
||||
|
||||
OGLE::camera.set_position({corner_pos/2,1,corner_pos/2});
|
||||
|
||||
maze = new Maze("resources/Map.tga", 2, ground, wall, out, raptor_model);
|
||||
OGLE::camera.set_position({static_cast<double>(maze->map.width*maze->scaling_factor/2.0),
|
||||
1,
|
||||
static_cast<double>(maze->map.width*maze->scaling_factor/2.0)});
|
||||
|
||||
// Fill colour is sky blue.
|
||||
glClearColor(0.53,0.81,0.75,1);
|
||||
|
|
Loading…
Add table
Reference in a new issue