diff options
author | Paul Gilbert | 2014-08-14 20:49:30 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-08-14 20:49:30 -0400 |
commit | f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea (patch) | |
tree | f6dc98367b9d60752ce1dc3a9538fa3fdf2f4cd5 /engines/access/player.cpp | |
parent | cf901ae142044227f5c34c33ab45eb8a0351ce93 (diff) | |
download | scummvm-rg350-f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea.tar.gz scummvm-rg350-f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea.tar.bz2 scummvm-rg350-f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea.zip |
ACCESS: Implemented player walk methods
Diffstat (limited to 'engines/access/player.cpp')
-rw-r--r-- | engines/access/player.cpp | 400 |
1 files changed, 399 insertions, 1 deletions
diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 969df0025f..6fab689ee0 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -50,6 +50,9 @@ Player::Player(AccessEngine *vm): Manager(vm) { _upDelta = _downDelta = 0; _scrollConst = 0; _roomNumber = 0; + _collideFlag = false; + _move = NONE; + _playerDirection = NONE; } void Player::load() { @@ -148,7 +151,53 @@ void Player::calcManScale() { } void Player::walk() { - warning("TODO: Player::walk"); + _collideFlag = false; + _playerDirection = NONE; + + if (_playerOff != 0) + return; + else if (_vm->_timerFlag) { + plotCom3(); + return; + } + + switch (_move) { + case UP: + _vm->_events->_mouseMove = false; + walkUp(); + break; + case DOWN: + _vm->_events->_mouseMove = false; + walkDown(); + break; + case LEFT: + _vm->_events->_mouseMove = false; + walkLeft(); + break; + case RIGHT: + _vm->_events->_mouseMove = false; + walkRight(); + break; + case UPLEFT: + _vm->_events->_mouseMove = false; + walkUpLeft(); + break; + case DOWNLEFT: + _vm->_events->_mouseMove = false; + walkDownLeft(); + break; + case UPRIGHT: + _vm->_events->_mouseMove = false; + walkUpRight(); + break; + case DOWNRIGHT: + _vm->_events->_mouseMove = false; + walkDownRight(); + break; + default: + checkMove(); + break; + } } void Player::calcPlayer() { @@ -159,4 +208,353 @@ void Player::calcPlayer() { _playerY = _rawPlayer.y - scr._bufferStart.y; } +void Player::walkUp() { + if (_frame > _upWalkMax || _frame < _upWalkMin) + _frame = _upWalkMin; + + _playerDirection = UP; + int walkOff = _walkOffUp[_frame - _upWalkMin]; + _rawYTempL = _vm->_screen->_scaleTable2[walkOff]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff]; + _rawXTemp = _rawPlayer.x; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.y = _rawYTempL; + + calcManScale(); + if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) { + error("TODO: si = 0?"); + // si = 0 + } + + if (++_frame > _upWalkMax) + _frame = _upWalkMin; + + plotCom(0); + } +} + +void Player::walkDown() { + if (_frame > _downWalkMax || _frame < _downWalkMin) + _frame = _downWalkMin; + + _playerDirection = DOWN; + int walkOff = _walkOffDown[_frame - _downWalkMin]; + _rawYTempL = _vm->_screen->_scaleTable2[walkOff]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff]; + _rawXTemp = _rawPlayer.x; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.y = _rawYTempL; + + calcManScale(); + if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) { + error("TODO: si = 0?"); + // si = 0 + } + + if (++_frame > _upWalkMax) + _frame = _upWalkMin; + + plotCom(0); + } +} + +void Player::walkLeft() { + if (_frame > _sideWalkMax || _frame < _sideWalkMin) + _frame = _sideWalkMin; + + _playerDirection = LEFT; + + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + int walkOffset = _walkOffLeft[_frame - _sideWalkMin]; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + _rawYTemp = _rawPlayer.y; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayerLow.x = _rawTempL; + ++_frame; + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _sideWalkMax) + _frame = _sideWalkMin; + + plotCom1(); + } +} + +void Player::walkRight() { + if (_frame > _sideWalkMax || _frame < _sideWalkMin) + _frame = _sideWalkMin; + + _playerDirection = RIGHT; + + bool flag = _vm->_screen->_scrollEnd == 2; + if (!flag) { + calcPlayer(); + flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + int walkOffset = _walkOffLeft[_frame - _sideWalkMin]; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + _rawYTemp = _rawPlayer.y; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayerLow.x = _rawTempL; + ++_frame; + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _sideWalkMax) + _frame = _sideWalkMin; + + plotCom1(); + } +} + +void Player::walkUpLeft() { + if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin) + _frame = _diagUpWalkMin; + + _playerDirection = UPLEFT; + + int walkOffset; + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + + walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y; + _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.x = _rawTempL; + _rawPlayerLow.y = _rawYTempL; + + ++_frame; + calcManScale(); + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _diagUpWalkMax) + _frame = _diagUpWalkMin; + + plotCom1(); + } +} + +void Player::walkDownLeft() { + if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin) + _frame = _diagDownWalkMin; + + _playerDirection = DOWNLEFT; + + int walkOffset; + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + walkOffset = _walkOffDL[_frame - _sideWalkMin].x; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + + walkOffset = _walkOffDL[_frame - _diagDownWalkMin].y; + _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.x = _rawTempL; + _rawPlayerLow.y = _rawYTempL; + + ++_frame; + calcManScale(); + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _diagDownWalkMax) + _frame = _diagDownWalkMin; + + plotCom1(); + } +} + +void Player::walkUpRight() { + if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin) + _frame = _diagUpWalkMin; + + _playerDirection = UPLEFT; + + int walkOffset; + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + + walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y; + _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.x = _rawTempL; + _rawPlayerLow.y = _rawYTempL; + + ++_frame; + calcManScale(); + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _diagUpWalkMax) + _frame = _diagUpWalkMin; + + plotCom(0); + } +} + +void Player::walkDownRight() { + if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin) + _frame = _diagDownWalkMin; + + _playerDirection = DOWNRIGHT; + + int walkOffset; + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + walkOffset = _walkOffUR[_frame - _sideWalkMin].x; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } + else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + + walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y; + _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.x = _rawTempL; + _rawPlayerLow.y = _rawYTempL; + + ++_frame; + calcManScale(); + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _diagDownWalkMax) + _frame = _diagDownWalkMin; + + plotCom1(); + } +} + +void Player::checkMove() { + error("TODO"); +} + +void Player::plotCom(int v) { + error("TODO"); +} + +void Player::plotCom1() { + plotCom(2); +} + +void Player::plotCom2() { + error("TODO"); +} + +void Player::plotCom3() { + error("TODO"); +} + +bool Player::codeWalls() { + error("TODO"); +} + } // End of namespace Access |