mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-20 13:25:10 +00:00
add colors to upper_floor
This commit is contained in:
@@ -19,7 +19,7 @@ namespace BBM
|
||||
if (!(i % 2) && !(j % 2)) {
|
||||
scene->addEntity("Unbreakable Wall")
|
||||
.addComponent<PositionComponent>(Vector3f(i, 0, j))
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>(UnbreakableObj, std::make_pair(MAP_DIFFUSE, UnbreakablePnj));
|
||||
}
|
||||
}
|
||||
@@ -33,19 +33,19 @@ namespace BBM
|
||||
|
||||
scene->addEntity("Bottom Wall")
|
||||
.addComponent<PositionComponent>(Vector3f((width + 1) / 2, 0, -1))
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>(UnbreakableObj, std::make_pair(MAP_DIFFUSE, UnbreakablePnj), RAY::Vector3(width + 3, 1, 1));
|
||||
scene->addEntity("Upper Wall")
|
||||
.addComponent<PositionComponent>(Vector3f((width + 1) / 2, 0, height + 1))
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>(UnbreakableObj, std::make_pair(MAP_DIFFUSE, UnbreakablePnj), RAY::Vector3(width + 3, 1, 1));
|
||||
scene->addEntity("Left Wall")
|
||||
.addComponent<PositionComponent>(Vector3f(width + 1, 0, height / 2))
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>(UnbreakableObj, std::make_pair(MAP_DIFFUSE, UnbreakablePnj), RAY::Vector3(1, 1, height + 1));
|
||||
scene->addEntity("Right Wall")
|
||||
.addComponent<PositionComponent>(Vector3f(-1, 0, height / 2))
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>(UnbreakableObj, std::make_pair(MAP_DIFFUSE, UnbreakablePnj), RAY::Vector3(1, 1, height + 1));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace BBM
|
||||
if (map[std::make_tuple(i, 0, j)] != HOLE && map[std::make_tuple(i, 0, j)] != BUMPER)
|
||||
scene->addEntity("Unbreakable Wall")
|
||||
.addComponent<PositionComponent>(Vector3f(i, -1, j))
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/floor.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/floor.png"));
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,8 @@ namespace BBM
|
||||
{HOLE, &createHole},
|
||||
{FLOOR, &createFloor},
|
||||
{BUMPER, &createBumper},
|
||||
{STAIRS, &createStairs}
|
||||
{STAIRS, &createStairs},
|
||||
{UPPERFLOOR, &createUpperFloor},
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -86,23 +87,32 @@ namespace BBM
|
||||
scene->addEntity("Breakable Block")
|
||||
.addComponent<PositionComponent>(coords)
|
||||
.addComponent<HealthComponent>(1)
|
||||
.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/breakable_wall.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/breakable_wall.png"));
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/breakatble_wall.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/breakable_wall.png"));
|
||||
}
|
||||
|
||||
void MapGenerator::createFloor(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
|
||||
{
|
||||
scene->addEntity("Floor")
|
||||
.addComponent<PositionComponent>(Vector3f(coords))
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/floor.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/floor.png"));
|
||||
}
|
||||
|
||||
void MapGenerator::createUpperFloor(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
|
||||
{
|
||||
scene->addEntity("Upper Floor")
|
||||
.addComponent<PositionComponent>(Vector3f(coords))
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/upper_floor.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/upper_floor.png"));
|
||||
}
|
||||
|
||||
|
||||
void MapGenerator::createUnbreakable(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
|
||||
{
|
||||
scene->addEntity("Unbreakable Block")
|
||||
.addComponent<PositionComponent>(coords)
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/unbreakable_wall.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/unbreakable_wall.png"));
|
||||
}
|
||||
|
||||
@@ -110,27 +120,27 @@ namespace BBM
|
||||
{
|
||||
scene->addEntity("Hole Block")
|
||||
.addComponent<PositionComponent>(Vector3f(coords.x, coords.y - 1, coords.z))
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/hole.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/hole.png"))
|
||||
.addComponent<CollisionComponent>([](const WAL::Entity &entity, WAL::Entity &other) {
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/hole.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/hole.png"));
|
||||
/* .addComponent<CollisionComponent>([](WAL::Entity &other, const WAL::Entity &entity) {
|
||||
if (other.hasComponent<HealthComponent>()) {
|
||||
auto &health = other.getComponent<HealthComponent>();
|
||||
health.takeDmg(health.getHealthPoint());
|
||||
}
|
||||
});
|
||||
}, [](WAL::Entity &other, const WAL::Entity &entity){}); */
|
||||
}
|
||||
|
||||
void MapGenerator::createBumper(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
|
||||
{
|
||||
std::cout << "Bumper Created" << std::endl;
|
||||
scene->addEntity("Bumper Block")
|
||||
.addComponent<PositionComponent>(Vector3f(coords.x, coords.y - 1, coords.z))
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/bumper.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/bumper.png"))
|
||||
.addComponent<CollisionComponent>([](const WAL::Entity &entity, WAL::Entity &other) {
|
||||
.addComponent<PositionComponent>(Vector3f(coords.x, coords.y, coords.z))
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/bumper.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/bumper.png"));
|
||||
/* .addComponent<CollisionComponent>([](const WAL::Entity &entity, WAL::Entity &other) {
|
||||
if (other.hasComponent<MovableComponent>()) {
|
||||
auto &movable = other.getComponent<MovableComponent>();
|
||||
movable.addForce(Vector3f(0, 5, 0));
|
||||
}
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
void MapGenerator::createStairs(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
|
||||
@@ -138,7 +148,7 @@ namespace BBM
|
||||
std::cout << "Stairs Created" << std::endl;
|
||||
scene->addEntity("Stairs Block")
|
||||
.addComponent<PositionComponent>(coords)
|
||||
.addComponent<CollisionComponent>(1)
|
||||
//.addComponent<CollisionComponent>(1)
|
||||
.addComponent<Drawable3DComponent<RAY3D::Model>>("assets/wall/stairs.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/stairs.png"));
|
||||
}
|
||||
|
||||
@@ -163,23 +173,25 @@ namespace BBM
|
||||
|
||||
MapGenerator::MapBlock MapGenerator::createHeight(MapBlock map, int width, int height)
|
||||
{
|
||||
double rnd = static_cast<double>(std::rand())/RAND_MAX;
|
||||
//double rnd = static_cast<double>(std::rand())/RAND_MAX;
|
||||
|
||||
double rnd = 1;
|
||||
|
||||
std::cout << "Height rnd" << rnd << std::endl;
|
||||
if (rnd > 0.60) {
|
||||
std::cout << "Up border" << std::endl;
|
||||
for (int i = 0; i < width + 1; i++) {
|
||||
map[std::make_tuple(i, 1, height)] = map[std::make_tuple(i, 0, height)];
|
||||
map[std::make_tuple(i, 0, height)] = FLOOR;
|
||||
map[std::make_tuple(i, 0, height)] = UPPERFLOOR;
|
||||
map[std::make_tuple(i, 1, 0)] = map[std::make_tuple(i, 0, 0)];
|
||||
map[std::make_tuple(i, 0, 0)] = FLOOR;
|
||||
map[std::make_tuple(i, 0, 0)] = UPPERFLOOR;
|
||||
}
|
||||
map[std::make_tuple(0, 0, height - 1)] = STAIRS;
|
||||
map[std::make_tuple(0, 0, 1)] = STAIRS;
|
||||
map[std::make_tuple(width, 0, height - 1)] = STAIRS;
|
||||
map[std::make_tuple(width, 0, 1)] = STAIRS;
|
||||
map[std::make_tuple(width / 2, -1, height - 1)] = BUMPER;
|
||||
map[std::make_tuple(width / 2, -1, 1)] = BUMPER;
|
||||
map[std::make_tuple(width / 2, 0, height - 1)] = BUMPER;
|
||||
map[std::make_tuple(width / 2, 0, 1)] = BUMPER;
|
||||
}
|
||||
if (rnd > 0.30) {
|
||||
std::cout << "Up center" << std::endl;
|
||||
@@ -188,7 +200,7 @@ namespace BBM
|
||||
if (map[std::make_tuple(i, 0, j)] == FLOOR)
|
||||
continue;
|
||||
map[std::make_tuple(i, 1, j)] = map[std::make_tuple(i, 0, j)];
|
||||
map[std::make_tuple(i, 0, j)] = FLOOR;
|
||||
map[std::make_tuple(i, 0, j)] = UPPERFLOOR;
|
||||
}
|
||||
}
|
||||
map[std::make_tuple(width / 2 - width / 8, 0, height / 2 + height / 4 + 1)] = STAIRS;
|
||||
@@ -209,6 +221,18 @@ namespace BBM
|
||||
return map;
|
||||
}
|
||||
|
||||
MapGenerator::MapBlock MapGenerator::cleanBreakable(MapBlock map, int width, int height)
|
||||
{
|
||||
for (int i = 0; i < width + 1; i++)
|
||||
for (int j = 0; j < height; j++) {
|
||||
if (map[std::make_tuple(i, 0, j)] == BREAKABLE && isCloseToBlockType(map, i, 0, j, STAIRS))
|
||||
map[std::make_tuple(i, 0, j)] = NOTHING;
|
||||
if (map[std::make_tuple(i, 0, j)] == BREAKABLE && map[std::make_tuple(i, -1, j)] == BUMPER)
|
||||
map[std::make_tuple(i, 0, j)] = NOTHING;
|
||||
}
|
||||
return (map);
|
||||
}
|
||||
|
||||
MapGenerator::MapBlock MapGenerator::createMap(int width, int height)
|
||||
{
|
||||
MapBlock map;
|
||||
@@ -237,6 +261,7 @@ namespace BBM
|
||||
if (!((i + 1) % 2) && !((j + 1) % 2))
|
||||
map[std::make_tuple(i, 0, j)] = UNBREAKABLE;
|
||||
map = createHeight(map, width, height);
|
||||
map = cleanBreakable(map, width, height);
|
||||
return (map);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user