Added a function to manage movement inside the maze.

Added goal and objective to the test maze.
This commit is contained in:
trotFunky 2019-11-04 00:12:43 +01:00
parent dfe279b236
commit 55f67099cb
4 changed files with 46 additions and 18 deletions

View file

@ -2,13 +2,13 @@
// Created by trotFunky on 03/11/2019.
//
#include "Engine.h"
#include <Engine.h>
#include "DataHandling/Texture.h"
#include "MovementManager.h"
#include "TileTypes.h"
static Texture map;
static constexpr float horizontal_speed = 0.025;
static constexpr float horizontal_speed = 0.05;
static constexpr int units_per_pixel = 2;
static constexpr int map_side = 32;
static constexpr int corner_pos = (map_side*units_per_pixel);
@ -21,38 +21,31 @@ void manage_inputs()
exit(EXIT_SUCCESS);
}
Vec3d horizontal_movement = OGLE::camera.get_gaze();
horizontal_movement.y = 0;
horizontal_movement.normalize();
Vec3d previous_camera_position = OGLE::camera.get_eyepos();
Vec3d translation{0,0,0};
// TODO : camera_translate function in MovementManager that handles both the correct translation and rollback.
if (InputStatus::is_special_key_pressed(GLUT_KEY_RIGHT))
{
OGLE::camera.local_translate({0, 0, horizontal_speed});
translation.z += horizontal_speed;
}
if (InputStatus::is_special_key_pressed(GLUT_KEY_LEFT))
{
OGLE::camera.local_translate({0, 0, -horizontal_speed});
translation.z -= horizontal_speed;
}
if (InputStatus::is_special_key_pressed(GLUT_KEY_UP))
{
OGLE::camera.translate(horizontal_movement * horizontal_speed);
translation.x += horizontal_speed;
}
if (InputStatus::is_special_key_pressed(GLUT_KEY_DOWN))
{
OGLE::camera.translate(horizontal_movement * -horizontal_speed);
translation.x -= horizontal_speed;
}
constrained_translation(translation,OGLE::camera,map,units_per_pixel);
Vec3i map_colour = current_map_colour(OGLE::camera.get_eyepos(), map, units_per_pixel);
if (map_colour == wall)
{
// If we are going into a wall, revert
OGLE::camera.set_position(previous_camera_position);
}
else if (map_colour == end)
if (map_colour == end)
{
std::cout << "Success !" << std::endl;
glutDestroyWindow(glutGetWindow());
@ -105,7 +98,7 @@ int main(int argc, char** argv)
{
OGLE::setup(argc,argv,display,"The Labyrinth !");
map.load_rgb_tga("resources/map.tga");
map.load_rgb_tga("resources/Map.tga");
OGLE::camera.set_position({corner_pos/2,1,corner_pos/2});