[Scummvm-git-logs] scummvm master -> c04b48db55bff06288ace7e4f7ac937fe9457a36
neuromancer
noreply at scummvm.org
Sat Nov 12 17:06:26 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b679362793 FREESCAPE: improved code that renders shoots
c04b48db55 FREESCAPE: implemented size of step for driller (and a basic implementation for other games)
Commit: b6793627936f45bbd6f6d14573ec98990a67caf4
https://github.com/scummvm/scummvm/commit/b6793627936f45bbd6f6d14573ec98990a67caf4
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-12T14:02:03+01:00
Commit Message:
FREESCAPE: improved code that renders shoots
Changed paths:
engines/freescape/gfx.h
engines/freescape/gfx_opengl.cpp
engines/freescape/gfx_opengl.h
engines/freescape/gfx_tinygl.cpp
engines/freescape/gfx_tinygl.h
engines/freescape/movement.cpp
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 9fb4d6c6d65..50a42154b04 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -81,7 +81,7 @@ public:
virtual void freeTexture(Texture *texture) = 0;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) = 0;
- virtual void renderShoot(byte color, const Common::Point position) = 0;
+ virtual void renderShoot(byte color, const Common::Point position, const Common::Rect viewPort) = 0;
virtual void renderCube(const Math::Vector3d &position, const Math::Vector3d &size, Common::Array<uint8> *colours);
virtual void renderRectangle(const Math::Vector3d &position, const Math::Vector3d &size, Common::Array<uint8> *colours);
virtual void renderPolygon(const Math::Vector3d &origin, const Math::Vector3d &size, const Common::Array<uint16> *ordinates, Common::Array<uint8> *colours);
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index f10aa9ec0c6..b7310a3b2c3 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -172,7 +172,7 @@ void OpenGLRenderer::positionCamera(const Math::Vector3d &pos, const Math::Vecto
glTranslatef(-pos.x(), -pos.y(), -pos.z());
}
-void OpenGLRenderer::renderShoot(byte color, const Common::Point position) {
+void OpenGLRenderer::renderShoot(byte color, const Common::Point position, const Common::Rect viewArea) {
uint8 r, g, b;
readFromPalette(color, r, g, b); // TODO: should use opposite color
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index f81bf1cf3ec..134bb248717 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -73,7 +73,7 @@ public:
void freeTexture(Texture *texture) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) override;
- virtual void renderShoot(byte color, const Common::Point position) override;
+ virtual void renderShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
virtual void flipBuffer() override;
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index ab2cff7cb78..a6ea6dc6138 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -122,7 +122,7 @@ void TinyGLRenderer::positionCamera(const Math::Vector3d &pos, const Math::Vecto
tglTranslatef(-pos.x(), -pos.y(), -pos.z());
}
-void TinyGLRenderer::renderShoot(byte color, const Common::Point position) {
+void TinyGLRenderer::renderShoot(byte color, const Common::Point position, const Common::Rect viewArea) {
uint8 r, g, b;
readFromPalette(color, r, g, b); // TODO: should use opposite color
@@ -141,14 +141,14 @@ void TinyGLRenderer::renderShoot(byte color, const Common::Point position) {
tglGetIntegerv(TGL_VIEWPORT, viewPort);
tglEnableClientState(TGL_VERTEX_ARRAY);
- copyToVertexArray(0, Math::Vector3d(0, _screenH - 2, 0));
+ copyToVertexArray(0, Math::Vector3d(viewArea.left, viewArea.height() + viewArea.top - 1, 0));
copyToVertexArray(1, Math::Vector3d(position.x, position.y, 0));
- copyToVertexArray(2, Math::Vector3d(0, _screenH - 2, 0));
+ copyToVertexArray(2, Math::Vector3d(viewArea.left, viewArea.height() + viewArea.top - 1, 0));
copyToVertexArray(3, Math::Vector3d(position.x, position.y, 0));
- copyToVertexArray(4, Math::Vector3d(_screenW, _screenH - 2, 0));
+ copyToVertexArray(4, Math::Vector3d(viewArea.right, viewArea.width() - viewArea.bottom, 0));
copyToVertexArray(5, Math::Vector3d(position.x, position.y, 0));
- copyToVertexArray(6, Math::Vector3d(_screenW, _screenH, 0));
+ copyToVertexArray(6, Math::Vector3d(viewArea.right, viewArea.width() - viewArea.bottom, 0));
copyToVertexArray(7, Math::Vector3d(position.x, position.y, 0));
tglVertexPointer(3, TGL_FLOAT, 0, _verts);
diff --git a/engines/freescape/gfx_tinygl.h b/engines/freescape/gfx_tinygl.h
index 7f79a73b36a..1bfc7eab0b3 100644
--- a/engines/freescape/gfx_tinygl.h
+++ b/engines/freescape/gfx_tinygl.h
@@ -59,7 +59,7 @@ public:
void freeTexture(Texture *texture) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) override;
- virtual void renderShoot(byte color, const Common::Point position) override;
+ virtual void renderShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
virtual void flipBuffer() override;
diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index 43104ffda2c..42e70bfeefb 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -60,7 +60,7 @@ void FreescapeEngine::shoot() {
//_mixer->stopHandle(_soundFxHandle);
playSound(1, true);
_gfx->setViewport(_fullscreenViewArea);
- _gfx->renderShoot(0, _crossairPosition);
+ _gfx->renderShoot(0, _crossairPosition, _viewArea);
_gfx->setViewport(_viewArea);
Common::Point center(_viewArea.left + _viewArea.width() / 2, _viewArea.top + _viewArea.height() / 2);
Commit: c04b48db55bff06288ace7e4f7ac937fe9457a36
https://github.com/scummvm/scummvm/commit/c04b48db55bff06288ace7e4f7ac937fe9457a36
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-12T18:07:20+01:00
Commit Message:
FREESCAPE: implemented size of step for driller (and a basic implementation for other games)
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/games/driller.cpp
engines/freescape/movement.cpp
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index f5ec93d560e..ae45f07f2fc 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -80,6 +80,17 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
_noClipMode = false;
_playerHeightNumber = 1;
_angleRotationIndex = 0;
+
+ // TODO: this is not the same for every game
+ _playerStepIndex = 6;
+ _playerSteps.push_back(1);
+ _playerSteps.push_back(2);
+ _playerSteps.push_back(5);
+ _playerSteps.push_back(10);
+ _playerSteps.push_back(25);
+ _playerSteps.push_back(50);
+ _playerSteps.push_back(100);
+
_border = nullptr;
_title = nullptr;
_titleTexture = nullptr;
@@ -321,6 +332,12 @@ void FreescapeEngine::processInput() {
case Common::KEYCODE_w:
rotate(_angleRotations[_angleRotationIndex], 0);
break;
+ case Common::KEYCODE_s:
+ increaseStepSize();
+ break;
+ case Common::KEYCODE_x:
+ decreaseStepSize();
+ break;
case Common::KEYCODE_r:
rise();
break;
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 5d3bc3fb8c8..7c10123a71a 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -164,7 +164,9 @@ public:
void generateInput();
virtual void pressedKey(const int keycode);
void move(CameraMovement direction, uint8 scale, float deltaTime);
- void changePlayerHeight(int delta);
+ void changePlayerHeight(int index);
+ void increaseStepSize();
+ void decreaseStepSize();
void rise();
void lower();
bool checkFloor(Math::Vector3d currentPosition);
@@ -205,6 +207,9 @@ public:
uint16 _playerWidth;
uint16 _playerDepth;
+ int _playerStepIndex;
+ Common::Array<int> _playerSteps;
+
// Effects
Common::Array<Common::String> _conditionSources;
Common::Array<FCLInstructionVector> _conditions;
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index f4cbe659b71..31752cbd4cb 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -375,6 +375,7 @@ void DrillerEngine::drawDOSUI(Graphics::Surface *surface) {
else
drawStringInSurface(Common::String::format("%s", "J"), 57, 161, yellow, black, surface);
+ drawStringInSurface(Common::String::format("%3d", _playerSteps[_playerStepIndex]), 46, 153, yellow, black, surface);
drawStringInSurface(Common::String::format("%07d", score), 240, 129, yellow, black, surface);
int hours = _countdown / 3600;
diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index 42e70bfeefb..4314fee6e95 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -95,6 +95,20 @@ void FreescapeEngine::changePlayerHeight(int index) {
_position.setValue(1, _position.y() + _playerHeight);
}
+void FreescapeEngine::increaseStepSize() {
+ if (_playerStepIndex == int(_playerSteps.size()) - 1)
+ return;
+
+ _playerStepIndex++;
+}
+
+void FreescapeEngine::decreaseStepSize() {
+ if (_playerStepIndex == 0)
+ return;
+
+ _playerStepIndex--;
+}
+
void FreescapeEngine::rise() {
debugC(1, kFreescapeDebugMove, "playerHeightNumber: %d", _playerHeightNumber);
int previousAreaID = _currentArea->getAreaID();
@@ -155,20 +169,22 @@ void FreescapeEngine::move(CameraMovement direction, uint8 scale, float deltaTim
debugC(1, kFreescapeDebugMove, "old player position: %f, %f, %f", _position.x(), _position.y(), _position.z());
int previousAreaID = _currentArea->getAreaID();
- float velocity = _movementSpeed * deltaTime;
+ Math::Vector3d stepFront = _cameraFront * (_playerSteps[_playerStepIndex] * 0.5 / _cameraFront.length());
+ Math::Vector3d stepRight = _cameraRight * (_playerSteps[_playerStepIndex] * 0.5 / _cameraRight.length());
+
float positionY = _position.y();
switch (direction) {
case kForwardMovement:
- _position = _position + _cameraFront * velocity;
+ _position = _position + stepFront;
break;
case kBackwardMovement:
- _position = _position - _cameraFront * velocity;
+ _position = _position - stepFront;
break;
case kRightMovement:
- _position = _position - _cameraRight * velocity;
+ _position = _position - stepRight;
break;
case kLeftMovement:
- _position = _position + _cameraRight * velocity;
+ _position = _position + stepRight;
break;
}
More information about the Scummvm-git-logs
mailing list