FREESCAPE: implemented size of step for driller (and a basic implementation for other games)

This commit is contained in:
neuromancer 2022-11-12 18:07:20 +01:00
parent b679362793
commit c04b48db55
4 changed files with 45 additions and 6 deletions

View file

@ -80,6 +80,17 @@ FreescapeEngine::FreescapeEngine(OSystem *syst, const ADGameDescription *gd)
_noClipMode = false; _noClipMode = false;
_playerHeightNumber = 1; _playerHeightNumber = 1;
_angleRotationIndex = 0; _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; _border = nullptr;
_title = nullptr; _title = nullptr;
_titleTexture = nullptr; _titleTexture = nullptr;
@ -321,6 +332,12 @@ void FreescapeEngine::processInput() {
case Common::KEYCODE_w: case Common::KEYCODE_w:
rotate(_angleRotations[_angleRotationIndex], 0); rotate(_angleRotations[_angleRotationIndex], 0);
break; break;
case Common::KEYCODE_s:
increaseStepSize();
break;
case Common::KEYCODE_x:
decreaseStepSize();
break;
case Common::KEYCODE_r: case Common::KEYCODE_r:
rise(); rise();
break; break;

View file

@ -164,7 +164,9 @@ public:
void generateInput(); void generateInput();
virtual void pressedKey(const int keycode); virtual void pressedKey(const int keycode);
void move(CameraMovement direction, uint8 scale, float deltaTime); void move(CameraMovement direction, uint8 scale, float deltaTime);
void changePlayerHeight(int delta); void changePlayerHeight(int index);
void increaseStepSize();
void decreaseStepSize();
void rise(); void rise();
void lower(); void lower();
bool checkFloor(Math::Vector3d currentPosition); bool checkFloor(Math::Vector3d currentPosition);
@ -205,6 +207,9 @@ public:
uint16 _playerWidth; uint16 _playerWidth;
uint16 _playerDepth; uint16 _playerDepth;
int _playerStepIndex;
Common::Array<int> _playerSteps;
// Effects // Effects
Common::Array<Common::String> _conditionSources; Common::Array<Common::String> _conditionSources;
Common::Array<FCLInstructionVector> _conditions; Common::Array<FCLInstructionVector> _conditions;

View file

@ -375,6 +375,7 @@ void DrillerEngine::drawDOSUI(Graphics::Surface *surface) {
else else
drawStringInSurface(Common::String::format("%s", "J"), 57, 161, yellow, black, surface); 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); drawStringInSurface(Common::String::format("%07d", score), 240, 129, yellow, black, surface);
int hours = _countdown / 3600; int hours = _countdown / 3600;

View file

@ -95,6 +95,20 @@ void FreescapeEngine::changePlayerHeight(int index) {
_position.setValue(1, _position.y() + _playerHeight); _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() { void FreescapeEngine::rise() {
debugC(1, kFreescapeDebugMove, "playerHeightNumber: %d", _playerHeightNumber); debugC(1, kFreescapeDebugMove, "playerHeightNumber: %d", _playerHeightNumber);
int previousAreaID = _currentArea->getAreaID(); 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()); debugC(1, kFreescapeDebugMove, "old player position: %f, %f, %f", _position.x(), _position.y(), _position.z());
int previousAreaID = _currentArea->getAreaID(); 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(); float positionY = _position.y();
switch (direction) { switch (direction) {
case kForwardMovement: case kForwardMovement:
_position = _position + _cameraFront * velocity; _position = _position + stepFront;
break; break;
case kBackwardMovement: case kBackwardMovement:
_position = _position - _cameraFront * velocity; _position = _position - stepFront;
break; break;
case kRightMovement: case kRightMovement:
_position = _position - _cameraRight * velocity; _position = _position - stepRight;
break; break;
case kLeftMovement: case kLeftMovement:
_position = _position + _cameraRight * velocity; _position = _position + stepRight;
break; break;
} }