Commit 208c4ad1 authored by Elias Broschin's avatar Elias Broschin
Browse files

current gameplay status

parents 3ceea4db 62266b56
......@@ -116,12 +116,10 @@ namespace gdw {
if(input.mouseWheelY() < 0.f) {
auto cam = engine_.game_play_system().level_manager().camera();
cam->position(cam->position()+glm::vec3(0,1.f,1.f));
level_manager.set_weapon(weapon_type::tractor_beam);
}
if(input.mouseWheelY() > 0.f) {
auto cam = engine_.game_play_system().level_manager().camera();
cam->position(cam->position()+glm::vec3(0,-1.f,-1.f));
level_manager.set_weapon(weapon_type::portal_gun);
}
if(input.isPressed(inputMapping::beam_normal)) {
......@@ -183,45 +181,45 @@ namespace gdw {
if (input.isDown(inputMapping::beam_normal)) {
auto ray_length = (std::abs(ray_length_ - 0.f) < 0.001f)? glm::length(ray_unnormalized): ray_length_;
render_ray(&r, ray_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(0,0,1));
render_ray(&r, ray_length, std::max((beam_velocity/10.f), 1.f), glm::vec3(0,0,1));
} else {
auto ray_length = (std::abs(ray_length_ - 0.f) < 0.001f)? glm::length(ray_unnormalized): ray_length_;
render_ray(&r, ray_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(1,0,0));
render_ray(&r, ray_length, std::max((beam_velocity/10.f), 1.f), glm::vec3(1,0,0));
}
// do {
switch(portal_type) {
case 0: {
auto yellow_portal = level_manager.yellow_portal();
if(yellow_portal) {
ray r2(yellow_portal->position(), yellow_portal->position()+(r.source - r.destination));
portal_type = -1;
ray_length_ = remaining_length;
process_beam_collision(r2, ray_unnormalized, beam_velocity, ray_length_, asteroid_hit, portal_type, remaining_length);
if (input.isDown(inputMapping::beam_normal)) {
render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(0,0,1));
} else {
render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(1,0,0));
}
}
break;
}
case 1: {
auto blue_portal = level_manager.blue_portal();
if(blue_portal) {
ray r2(blue_portal->position(), blue_portal->position()+(r.source - r.destination));
portal_type = -1;
ray_length_ = remaining_length;
process_beam_collision(r2, ray_unnormalized, beam_velocity, ray_length_, asteroid_hit, portal_type, remaining_length);
if (input.isDown(inputMapping::beam_normal)) {
render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(0,0,1));
} else {
render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(1,0,0));
}
}
break;
}
default:{}
}
// switch(portal_type) {
// case 0: {
// auto yellow_portal = level_manager.yellow_portal();
// if(yellow_portal) {
// ray r2(yellow_portal->position(), yellow_portal->position()+(r.source - r.destination));
// portal_type = -1;
// ray_length_ = remaining_length;
// process_beam_collision(r2, ray_unnormalized, beam_velocity, ray_length_, asteroid_hit, portal_type, remaining_length);
// if (input.isDown(inputMaping::beam_normal)) {
// render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(0,0,1));
// } else {
// render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(1,0,0));
// }
// }
// break;
// }
// case 1: {
// auto blue_portal = level_manager.blue_portal();
// if(blue_portal) {
// ray r2(blue_portal->position(), blue_portal->position()+(r.destination - r.source));
// portal_type = -1;
// ray_length_ = remaining_length;
// process_beam_collision(r2, ray_unnormalized, beam_velocity, ray_length_, asteroid_hit, portal_type, remaining_length);
// if (input.isDown(inputMaping::beam_normal)) {
// render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(0,0,1));
// } else {
// render_ray(&r2, remaining_length, std::max((beam_velocity/10.f)/2.f, 1.f), glm::vec3(1,0,0));
// }
// }
// break;
// }
// default:{}
// }
// } while(portal_type > 0 || glm::length(remaining_length)<0.3f);
}
break;
......@@ -252,13 +250,10 @@ namespace gdw {
if(!type_comp) continue;
if(type_comp->get_object_type() == "ACCELERATOR") {
ray_length_ = asteroid_hit ? ray_length_ : ray_length_*1.5f;
beam_velocity += 10.f;
beam_velocity += 5.f;
}
}
//BEAM X ASTEROIDS
for(auto &coll : collider) {
auto c = engine_.entity_manager().resolve(coll);
......@@ -272,32 +267,32 @@ namespace gdw {
}
}
//BEAM X PORTAL
for(auto &coll : collider) {
// //BEAM X PORTAL
// for(auto &coll : collider) {
auto c = engine_.entity_manager().resolve(coll);
// auto c = engine_.entity_manager().resolve(coll);
auto type_comp = c->component<object_type_component>();
if(!type_comp) continue;
// auto type_comp = c->component<object_type_component>();
// if(!type_comp) continue;
if(type_comp->get_object_type() == "BLUE_PORTAL") {
if(glm::length(r.source - c->position()) > ray_length_) continue;
// if(type_comp->get_object_type() == "BLUE_PORTAL") {
// if(glm::length(r.source - c->position()) > ray_length_) continue;
auto reduced_ray_length = std::min(ray_length_, glm::length(c->position() - r.source));
remaining_ray_length = ray_length_ - reduced_ray_length;
ray_length_ = reduced_ray_length;
portal_type = 0;
}
// auto reduced_ray_length = std::min(ray_length_, glm::length(c->position() - r.source));
// remaining_ray_length = ray_length_ - reduced_ray_length;
// ray_length_ = reduced_ray_length;
// portal_type = 0;
// }
if(type_comp->get_object_type() == "YELLOW_PORTAL") {
if(glm::length(r.source - c->position()) > ray_length_) continue;
// if(type_comp->get_object_type() == "YELLOW_PORTAL") {
// if(glm::length(r.source - c->position()) > ray_length_) continue;
auto reduced_ray_length = std::min(ray_length_, glm::length(c->position() - r.source));
remaining_ray_length = ray_length_ - reduced_ray_length;
ray_length_ = reduced_ray_length;
portal_type = 1;
}
}
// auto reduced_ray_length = std::min(ray_length_, glm::length(c->position() - r.source));
// remaining_ray_length = ray_length_ - reduced_ray_length;
// ray_length_ = reduced_ray_length;
// portal_type = 1;
// }
// }
//BEAM X MOVINGS
for(auto &coll : collider) {
......
......@@ -30,6 +30,8 @@
#include <physics/collision_data_manager.hpp>
#include <physics/collision_data.hpp>
#include <physics/physics_system.h>
#include <string>
#include <util/make_unique.hpp>
namespace gdw {
......@@ -150,21 +152,6 @@ namespace gdw {
engine_.entity_manager().erase(id);
}
/*
for(int i = 0; i < items_.size(); i++) {
auto item = engine_.entity_manager().resolve(items_[i]);
if(!item) continue;
if(!(item->component<item_container_component>()->isActive())) {
del_queue.emplace_back(items_[i]);
}
}
for(auto &id : del_queue) {
list_helper::removeElement(items_, id);
engine_.entity_manager().erase(id);
}
*/
auto p = player();
if (!p) return;
......@@ -177,7 +164,7 @@ namespace gdw {
cannon->rotation(p->rotation());
// ----- ITEMS DROPS ------
unsigned int item_drop_chance = 100; // percent
unsigned int item_drop_chance = 25; // percent
for(auto &item : items_to_create) {
srand (time(0)*time(0));
if(rand()%100 <= item_drop_chance) {
......@@ -246,7 +233,11 @@ namespace gdw {
auto z_quat = glm::angleAxis(rotation.z, glm::vec3(0,0,1));
asteroid.rotation(x_quat * y_quat * z_quat * asteroid.rotation());
auto col_data = engine_.physics_system().collision_data_manager().load("physic/asteroid.col");
auto index = mesh_name.find_first_of('/');
auto col_name = mesh_name.substr(index+1, mesh_name.size());
col_name = col_name.substr(0, col_name.size()-4);
auto col_data = engine_.physics_system().collision_data_manager().load("physic/"+col_name+".col");
auto &asteroid_coll = asteroid.emplace_back<collision_component>(new sphere(col_data->center()+glm::vec3(0,(-pos.y)+3.f, 0), (scale/4.f) * glm::length(col_data->half_extend())));
asteroid.scale(glm::vec3(scale));
......@@ -263,7 +254,24 @@ namespace gdw {
auto &victim = entity_manager.emplace_back(glm::vec3(-40.f, 3.f, z), glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 1.f, 0.f)));
victim.scale(glm::vec3(0.4f));
auto col_data = engine_.physics_system().collision_data_manager().load("physic/pirate_ship.col");
srand(time(0)*time(0));
int r = rand() % 2 + 1;
std::string col_name = "";
std::string mesh_name = "";
switch(r) {
case 1: {
col_name = "physic/victim.col";
mesh_name = "mesh/victim.msh";
break;
}
case 2:
default: {
col_name = "physic/submarine.col";
mesh_name = "mesh/submarine.msh";
}
}
auto col_data = engine_.physics_system().collision_data_manager().load(col_name);
auto &victim_coll = victim.emplace_back<collision_component>(new sphere(col_data->center(), 0.3f * glm::length(col_data->half_extend())));
victim.emplace_back<object_type_component>("VICTIM");
......@@ -279,7 +287,7 @@ namespace gdw {
}
});
victim.emplace_back<staticmesh_component>("mesh/victim.msh");
victim.emplace_back<staticmesh_component>(mesh_name.c_str());
auto &lwyag = victim.emplace_back<look_where_you_are_going_component>();
lwyag.set_x_angle_lock(true);
lwyag.set_z_angle_lock(true);
......@@ -300,7 +308,6 @@ namespace gdw {
auto &item = entity_manager.emplace_back(glm::vec3(pos.x-1.f, 3.f, pos.z), glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 1.f, 0.f)));
item.emplace_back<staticmesh_component>("mesh/coin.msh", true);
// item.scale(glm::vec3(1f));
auto &lwyag = item.emplace_back<look_where_you_are_going_component>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment