summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-19 22:18:58 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-19 22:18:58 +0300
commitda73354d0c3d9cf8507fe9d88a5e778fdbb7fa44 (patch)
treed05a33c0a234c4a9386639bf742239f3cedd50d6
parent41b8151a3f04bc1cb0127bdf5c10e0dd8275bad5 (diff)
downloadmv-da73354d0c3d9cf8507fe9d88a5e778fdbb7fa44.tar.gz
mv-da73354d0c3d9cf8507fe9d88a5e778fdbb7fa44.tar.bz2
mv-da73354d0c3d9cf8507fe9d88a5e778fdbb7fa44.tar.xz
mv-da73354d0c3d9cf8507fe9d88a5e778fdbb7fa44.zip
add new parallax attributes.
Old attribute: parallax New attributes: parallaxX, parallaxY Before parallax was used for x and y. If parallaxX or parallaxY missing can be used parallax.
-rw-r--r--src/map.cpp11
-rw-r--r--src/resources/ambientlayer.cpp10
-rw-r--r--src/resources/ambientlayer.h6
3 files changed, 18 insertions, 9 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 9d5eafc7b..d080406c6 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -286,8 +286,10 @@ void Map::initializeAmbientLayers()
int mask = atoi(getProperty(name + "mask").c_str());
if (!mask)
mask = 1;
+ const float parallax = getFloatProperty(name + "parallax");
mForegrounds.push_back(new AmbientLayer(img,
- getFloatProperty(name + "parallax"),
+ getFloatProperty(name + "parallaxX", parallax),
+ getFloatProperty(name + "parallaxY", parallax),
getFloatProperty(name + "scrollX"),
getFloatProperty(name + "scrollY"),
getBoolProperty(name + "keepratio"),
@@ -310,8 +312,11 @@ void Map::initializeAmbientLayers()
int mask = atoi(getProperty(name + "mask").c_str());
if (!mask)
mask = 1;
- mBackgrounds.push_back(new AmbientLayer(img,
- getFloatProperty(name + "parallax"),
+
+ const float parallax = getFloatProperty(name + "parallax");
+ mForegrounds.push_back(new AmbientLayer(img,
+ getFloatProperty(name + "parallaxX", parallax),
+ getFloatProperty(name + "parallaxY", parallax),
getFloatProperty(name + "scrollX"),
getFloatProperty(name + "scrollY"),
getBoolProperty(name + "keepratio"),
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 361b2e391..b74ba96db 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -31,11 +31,13 @@
#include "debug.h"
-AmbientLayer::AmbientLayer(Image *const img, const float parallax,
+AmbientLayer::AmbientLayer(Image *const img,
+ const float parallaxX, const float parallaxY,
const float speedX, const float speedY,
const bool keepRatio, const int mask) :
mImage(img),
- mParallax(parallax),
+ mParallaxX(parallaxX),
+ mParallaxY(parallaxY),
mPosX(0),
mPosY(0),
mSpeedX(speedX),
@@ -90,8 +92,8 @@ void AmbientLayer::update(const int timePassed, const float dx, const float dy)
mPosY -= mSpeedY * time;
// Parallax scrolling
- mPosX += dx * mParallax;
- mPosY += dy * mParallax;
+ mPosX += dx * mParallaxX;
+ mPosY += dy * mParallaxY;
const SDL_Rect &rect = mImage->mBounds;
const float imgW = rect.w;
diff --git a/src/resources/ambientlayer.h b/src/resources/ambientlayer.h
index 4ce13179e..ab8202ba7 100644
--- a/src/resources/ambientlayer.h
+++ b/src/resources/ambientlayer.h
@@ -43,7 +43,8 @@ class AmbientLayer final
* @param keepRatio rescale the image to keep
* the same ratio than in 800x600 resolution mode.
*/
- AmbientLayer(Image *const img, const float parallax,
+ AmbientLayer(Image *const img,
+ const float parallax, const float parallaxY,
const float speedX, const float speedY,
const bool keepRatio, const int mask);
@@ -57,7 +58,8 @@ class AmbientLayer final
private:
Image *mImage;
- float mParallax;
+ float mParallaxX;
+ float mParallaxY;
float mPosX; /**< Current layer X position. */
float mPosY; /**< Current layer Y position. */
float mSpeedX; /**< Scrolling speed in X direction. */