summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/ambientlayer.cpp27
-rw-r--r--src/resources/ambientlayer.h2
-rw-r--r--src/resources/resource.h2
3 files changed, 21 insertions, 10 deletions
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 2fa522e5..b292070b 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -21,7 +21,6 @@
#include "resources/ambientlayer.h"
#include "graphics.h"
-#include "video.h"
#include "resources/image.h"
#include "resources/resourcemanager.h"
@@ -30,8 +29,7 @@ AmbientLayer::AmbientLayer(Image *img)
: mImage(img)
{}
-AmbientLayer::~AmbientLayer()
-{}
+AmbientLayer::~AmbientLayer() = default;
void AmbientLayer::update(int timePassed, float dx, float dy)
{
@@ -58,14 +56,27 @@ void AmbientLayer::update(int timePassed, float dx, float dy)
mPosY += imgH;
}
-void AmbientLayer::draw(Graphics *graphics, int x, int y)
+void AmbientLayer::draw(Graphics *graphics)
{
+ const auto screenWidth = graphics->getWidth();
+ const auto screenHeight = graphics->getHeight();
+ const auto x = static_cast<int>(mPosX);
+ const auto y = static_cast<int>(mPosY);
+
if (!mKeepRatio)
+ {
graphics->drawImagePattern(mImage,
- (int) -mPosX, (int) -mPosY, x + (int) mPosX, y + (int) mPosY);
+ -x, -y,
+ screenWidth + x,
+ screenHeight + y);
+ }
else
+ {
graphics->drawRescaledImagePattern(mImage,
- (int) -mPosX, (int) -mPosY, x + (int) mPosX, y + (int) mPosY,
- (int) mImage->getWidth() / defaultScreenWidth * graphics->getWidth(),
- (int) mImage->getHeight() / defaultScreenHeight * graphics->getHeight());
+ -x, -y,
+ screenWidth + x,
+ screenHeight + y,
+ mImage->getWidth() * screenWidth / 800,
+ mImage->getHeight() * screenHeight / 600);
+ }
}
diff --git a/src/resources/ambientlayer.h b/src/resources/ambientlayer.h
index def2090b..e62af33f 100644
--- a/src/resources/ambientlayer.h
+++ b/src/resources/ambientlayer.h
@@ -39,7 +39,7 @@ class AmbientLayer
void update(int timePassed, float dx, float dy);
- void draw(Graphics *graphics, int x, int y);
+ void draw(Graphics *graphics);
float mParallax = 0; /**< Scroll factor based on camera position. */
float mSpeedX = 0; /**< Scrolling speed in X direction. */
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 7f1f4836..9fe00f3d 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -59,7 +59,7 @@ class Resource
{ return mIdPath; }
protected:
- virtual ~Resource() {}
+ virtual ~Resource() = default;
private:
std::string mIdPath; /**< Path identifying this resource. */