aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/iphone
diff options
context:
space:
mode:
authorsluicebox2019-11-16 13:49:27 -0800
committerEugene Sandulenko2019-11-19 00:20:40 +0100
commit40415a5c4a3dc78c495a89589e4590b71c0dbe77 (patch)
tree7d454afe90e29092889ef5358cd0973eb7dc4a2a /backends/platform/iphone
parent42217b5852fb0f871f78556b5bccf9403934ce08 (diff)
downloadscummvm-rg350-40415a5c4a3dc78c495a89589e4590b71c0dbe77.tar.gz
scummvm-rg350-40415a5c4a3dc78c495a89589e4590b71c0dbe77.tar.bz2
scummvm-rg350-40415a5c4a3dc78c495a89589e4590b71c0dbe77.zip
IPHONE: Implement horizontal shake
Diffstat (limited to 'backends/platform/iphone')
-rw-r--r--backends/platform/iphone/iphone_video.mm9
1 files changed, 6 insertions, 3 deletions
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index 1866bf5f96..dc9436bfd8 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -568,10 +568,11 @@ const char *iPhone_getDocumentsDir() {
// Scale the shake offset according to the overlay size. We need this to
// adjust the overlay mouse click coordinates when an offset is set.
+ _scaledShakeXOffset = (int)(_videoContext.shakeXOffset / (GLfloat)_videoContext.screenWidth * CGRectGetWidth(_overlayRect));
_scaledShakeYOffset = (int)(_videoContext.shakeYOffset / (GLfloat)_videoContext.screenHeight * CGRectGetHeight(_overlayRect));
// Apply the shaking to the output screen.
- glTranslatef(0, -_scaledShakeYOffset, 0);
+ glTranslatef(_scaledShakeXOffset, -_scaledShakeYOffset, 0);
}
- (void)clearColorBuffer {
@@ -637,23 +638,25 @@ const char *iPhone_getDocumentsDir() {
return false;
CGRect *area;
- int width, height, offsetY;
+ int width, height, offsetX, offsetY;
if (_videoContext.overlayVisible) {
area = &_overlayRect;
width = _videoContext.overlayWidth;
height = _videoContext.overlayHeight;
+ offsetX = _scaledShakeXOffset;
offsetY = _scaledShakeYOffset;
} else {
area = &_gameScreenRect;
width = _videoContext.screenWidth;
height = _videoContext.screenHeight;
+ offsetX = _videoContext.shakeXOffset;
offsetY = _videoContext.shakeYOffset;
}
point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area);
point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area);
- *x = (int)(point.x * width);
+ *x = (int)(point.x * width + offsetX);
// offsetY describes the translation of the screen in the upward direction,
// thus we need to add it here.
*y = (int)(point.y * height + offsetY);