diff --git a/assets/map/bumper.png b/assets/map/bumper.png index 63632844..e8502594 100644 Binary files a/assets/map/bumper.png and b/assets/map/bumper.png differ diff --git a/assets/map/outer_wall.mtl b/assets/map/outer_wall.mtl new file mode 100644 index 00000000..678256c4 --- /dev/null +++ b/assets/map/outer_wall.mtl @@ -0,0 +1,12 @@ +# Blender MTL File: 'None' +# Material Count: 1 + +newmtl cube +Ns 225.000000 +Ka 1.000000 1.000000 1.000000 +Kd 0.800000 0.800000 0.800000 +Ks 0.500000 0.500000 0.500000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 2 diff --git a/assets/map/outer_wall.obj b/assets/map/outer_wall.obj new file mode 100644 index 00000000..5152d0f2 --- /dev/null +++ b/assets/map/outer_wall.obj @@ -0,0 +1,54 @@ +# Blender v2.92.0 OBJ File: '' +# www.blender.org +mtllib unbreakable_wall.mtl +o cube +v -0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v 0.500000 0.500000 0.500000 +v -0.500000 0.500000 -0.500000 +v 0.500000 0.500000 -0.500000 +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 +vt 0.000000 0.000000 +vt 0.333333 0.000000 +vt 0.000000 0.500000 +vt 0.333333 0.500000 +vt 0.666666 1.000000 +vt 1.000000 1.000000 +vt 0.666666 0.500000 +vt 1.000000 0.500000 +vt 0.000000 1.000000 +vt 0.333333 1.000000 +vt 0.000000 0.500000 +vt 0.333333 0.500000 +vt 0.666666 0.000000 +vt 1.000000 0.000000 +vt 0.666666 0.500000 +vt 1.000000 0.500000 +vt 0.666666 0.500000 +vt 0.666666 1.000000 +vt 0.333333 0.000000 +vt 0.666666 0.000000 +vt 0.333333 0.500000 +vt 0.666666 0.500000 +vn 0.0000 -0.0000 1.0000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 -1.0000 -0.0000 +vn 1.0000 0.0000 0.0000 +vn -1.0000 0.0000 0.0000 +usemtl cube +s 1 +f 1/1/1 2/2/1 3/3/1 +f 3/3/1 2/2/1 4/4/1 +f 3/5/2 4/6/2 5/7/2 +f 5/7/2 4/6/2 6/8/2 +f 5/9/3 6/10/3 7/11/3 +f 7/11/3 6/10/3 8/12/3 +f 7/13/4 8/14/4 1/15/4 +f 1/15/4 8/14/4 2/16/4 +f 2/17/5 8/12/5 4/18/5 +f 4/18/5 8/12/5 6/10/5 +f 7/19/6 1/20/6 5/21/6 +f 5/21/6 1/20/6 3/22/6 diff --git a/assets/map/outer_wall.png b/assets/map/outer_wall.png new file mode 100644 index 00000000..e25f5252 Binary files /dev/null and b/assets/map/outer_wall.png differ diff --git a/sources/Items/Bonus.cpp b/sources/Items/Bonus.cpp index 68e4e9f3..6a579d43 100644 --- a/sources/Items/Bonus.cpp +++ b/sources/Items/Bonus.cpp @@ -46,7 +46,7 @@ namespace BBM { return; if (controllable->speed >= 0.4) return; - controllable->speed = 0.025f; + controllable->speed += 0.025f; const_cast(bonus).scheduleDeletion(); } diff --git a/sources/Map/Map.cpp b/sources/Map/Map.cpp index 305e94dd..d1d70223 100644 --- a/sources/Map/Map.cpp +++ b/sources/Map/Map.cpp @@ -29,7 +29,7 @@ namespace BBM if (!movable || !bumperTimer) return; if (!bumperTimer->_isReseting) { - movable->_velocity.y = 1.5; + movable->_velocity.y = 2; bumperTimer->_isReseting = true; } } @@ -113,6 +113,7 @@ namespace BBM const std::string MapGenerator::imageExtension = ".png"; const std::string MapGenerator::objExtension = ".obj"; const std::string MapGenerator::breakableWallPath = MapGenerator::wallAssetsPath + "breakable_wall"; + const std::string MapGenerator::outerWallPath = MapGenerator::wallAssetsPath + "outer_wall"; const std::string MapGenerator::unbreakableWallPath = MapGenerator::wallAssetsPath + "unbreakable_wall"; const std::string MapGenerator::floorPath = MapGenerator::wallAssetsPath + "floor"; const std::string MapGenerator::secondFloorPath = MapGenerator::wallAssetsPath + "upper_floor"; @@ -145,58 +146,55 @@ namespace BBM void MapGenerator::generateWall(int width, int height, std::shared_ptr scene) { - static const std::string unbreakableObj = unbreakableWallPath + objExtension; - static const std::string unbreakablePnj = unbreakableWallPath + imageExtension; + static const std::string outerWallObj = unbreakableWallPath + objExtension; + static const std::string outerWallPnj = unbreakableWallPath + imageExtension; - for (int i = 0; i < height + 1; i++) { + for (int i = -1; i < height + 2; i++) { scene->addEntity("Bomb stopper") .addComponent(-1, 0, i) - .addComponent>(); + .addComponent>() + .addComponent(outerWallObj, false, + std::make_pair(MAP_DIFFUSE, outerWallPnj)); scene->addEntity("Bomb stopper") .addComponent(width + 1, 0, i) - .addComponent>(); + .addComponent>() + .addComponent(outerWallObj, false, + std::make_pair(MAP_DIFFUSE, outerWallPnj)); } for (int i = 0; i < width + 1; i++) { scene->addEntity("Bomb stopper") .addComponent(i, 0, -1) - .addComponent>(); + .addComponent>() + .addComponent(outerWallObj, false, + std::make_pair(MAP_DIFFUSE, outerWallPnj)); scene->addEntity("Bomb stopper") .addComponent(i, 0, height + 1) - .addComponent>(); + .addComponent>() + .addComponent(outerWallObj, false, + std::make_pair(MAP_DIFFUSE, outerWallPnj)); } scene->addEntity("Bottom Wall") .addComponent(Vector3f((width + 1) / 2, 0, -1)) .addComponent( WAL::Callback(), - &MapGenerator::wallCollision, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) - .addComponent(unbreakableObj, false, - std::make_pair(MAP_DIFFUSE, unbreakablePnj), - RAY::Vector3(width + 3, 1, 1)); + &MapGenerator::wallCollision, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)); scene->addEntity("Upper Wall") .addComponent(Vector3f((width + 1) / 2, 0, height + 1)) .addComponent( WAL::Callback(), - &MapGenerator::wallCollision, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) - .addComponent(unbreakableObj, false, - std::make_pair(MAP_DIFFUSE, unbreakablePnj), - RAY::Vector3(width + 3, 1, 1)); + &MapGenerator::wallCollision, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)); scene->addEntity("Left Wall") .addComponent(Vector3f(width + 1, 0, height / 2)) .addComponent( WAL::Callback(), - &MapGenerator::wallCollision, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) - .addComponent(unbreakableObj, false, - std::make_pair(MAP_DIFFUSE, unbreakablePnj), - RAY::Vector3(1, 1, height + 1)); + &MapGenerator::wallCollision, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)); scene->addEntity("Right Wall") .addComponent(Vector3f(-1, 0, height / 2)) .addComponent( WAL::Callback(), - &MapGenerator::wallCollision, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) - .addComponent(unbreakableObj, false, - std::make_pair(MAP_DIFFUSE, unbreakablePnj), - RAY::Vector3(1, 1, height + 1)); + &MapGenerator::wallCollision, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)); + } void MapGenerator::generateFloor(MapBlock map, int width, int height, std::shared_ptr scene) @@ -331,13 +329,13 @@ namespace BBM map[std::make_tuple(x, y, z - 1)] == blockType); } - MapGenerator::BlockType MapGenerator::getRandomBlockType() + MapGenerator::BlockType MapGenerator::getRandomBlockType(bool hasHeight) { double rnd = static_cast(std::rand()) / RAND_MAX; - if (rnd > 0.98) + if (rnd > 0.98 && !hasHeight) return HOLE; - if (rnd > 0.25) + if ((!hasHeight && rnd > 0.25) || rnd > 0.7) return BREAKABLE; return NOTHING; } @@ -446,7 +444,7 @@ namespace BBM if (isCloseToBlockType(map, i, 0, j, SPAWNER)) { map[std::make_tuple(i, isNotClassic ? -1 : 0, j)] = isNotClassic ? BUMPER : NOTHING; } else { - map[std::make_tuple(i, 0, j)] = getRandomBlockType(); + map[std::make_tuple(i, 0, j)] = getRandomBlockType(isHeight); } if (map[std::make_tuple(i, 0, j)] == UNBREAKABLE && isCloseToBlockType(map, i, 0, j, UNBREAKABLE)) map[std::make_tuple(i, 0, j)] = BREAKABLE; @@ -501,7 +499,7 @@ namespace BBM .addComponent(Vector3f(width / 2 - width / 4, 0, height / 2 - height / 4)) .addComponent( WAL::Callback(), - &MapGenerator::wallCollided, Vector3f(0.25, 0.25, 0.25),Vector3f(width, 0.75, height / 2 + height / 4)); + &MapGenerator::wallCollided, Vector3f(0.25, 0.25, 0.25),Vector3f(width / 2 + width / 4, 0.75, height / 2 + height / 4)); } void MapGenerator::loadMap(int width, int height, MapBlock map, const std::shared_ptr &scene) diff --git a/sources/Map/Map.hpp b/sources/Map/Map.hpp index ff7b712e..0606cb54 100644 --- a/sources/Map/Map.hpp +++ b/sources/Map/Map.hpp @@ -49,7 +49,7 @@ namespace BBM using MapBlock = std::map, BlockType>; //! @brief Generate random block type - static BlockType getRandomBlockType(); + static BlockType getRandomBlockType(bool = false); //! @param map ASCII map //! @param x x index on the block @@ -160,6 +160,8 @@ namespace BBM static const std::string unbreakableWallPath; + static const std::string outerWallPath; + static const std::string breakableWallPath; static const std::string floorPath;