mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-03 18:31:17 +00:00
add little parallax
This commit is contained in:
@@ -54,6 +54,7 @@ namespace BBM
|
||||
constexpr const char Blowable[] = "Blowable";
|
||||
// interact with visual features like camera
|
||||
constexpr const char Player[] = "Player";
|
||||
constexpr const char Background[] = "Background";
|
||||
constexpr const char Unbreakable[] = "Unbreakable";
|
||||
constexpr const char Breakable[] = "Breakable";
|
||||
constexpr const char Hole[] = "Hole";
|
||||
|
||||
+1
-1
@@ -338,7 +338,7 @@ namespace BBM
|
||||
if (rnd > 0.98)
|
||||
return HOLE;
|
||||
if (rnd > 0.25)
|
||||
return BREAKABLE;
|
||||
return NOTHING;
|
||||
return NOTHING;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,13 @@ namespace BBM
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T2>
|
||||
Vector2<T> operator-(const Vector2<T2> &vec) const
|
||||
{
|
||||
return Vector2<T>(this->x - vec.x, this->y - vec.y);
|
||||
}
|
||||
|
||||
|
||||
template<typename T2>
|
||||
Vector2<T> &operator*=(T2 d)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,8 @@ namespace BBM
|
||||
.addComponent<Drawable2DComponent, RAY2D::Text>("", 60, RAY::Vector2(), ORANGE);
|
||||
scene->addEntity("background image")
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>(true, "assets/background.png", false)
|
||||
.addComponent<PositionComponent>();
|
||||
.addComponent<PositionComponent>()
|
||||
.addComponent<TagComponent<Background>>();
|
||||
MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16, hasHeights), scene);
|
||||
return scene;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,12 @@ namespace BBM
|
||||
cam.target += (newCameraPos.abs() - pos.position.abs()) / 10;
|
||||
newCameraPos.y = maxDist;
|
||||
newCameraPos.z -= 1;
|
||||
Vector3f pos2d(pos.position.abs().x,0, pos.position.abs().z);
|
||||
Vector3f newPos2d(newCameraPos.abs().x, 0, pos.position.abs().z);
|
||||
for (auto &[entity, backPos, _] : this->_wal.getScene()->view<PositionComponent, TagComponent<Background>>()) {
|
||||
backPos.position -= (newPos2d - pos2d) / 10;
|
||||
}
|
||||
pos.position += (newCameraPos.abs() - pos.position.abs()) / 10;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user