MADS: Cleanup of Player::updateFrame

This commit is contained in:
Paul Gilbert 2014-03-28 20:23:25 -04:00
parent 5abec8506b
commit 49278129f6
5 changed files with 15 additions and 11 deletions

View File

@ -218,9 +218,9 @@ SpriteSetCharInfo::SpriteSetCharInfo(Common::SeekableReadStream *s) {
_numEntries = s->readUint16LE();
for (int i = 0; i < 16; ++i)
_frameList[i] = s->readUint16LE();
_startFrames[i] = s->readUint16LE();
for (int i = 0; i < 16; ++i)
_frameList2[i] = s->readUint16LE();
_stopFrames[i] = s->readUint16LE();
for (int i = 0; i < 16; ++i)
_ticksList[i] = s->readUint16LE();

View File

@ -48,8 +48,8 @@ public:
int _totalFrames;
int _numEntries;
int _frameList2[16];
int _frameList[16];
int _startFrames[16];
int _stopFrames[16];
int _ticksList[16];
int _velocity;
int _ticksAmount;

View File

@ -237,6 +237,7 @@ void Game::sectionLoop() {
_player._targetFacing = _player._facing;
_player.selectSeries();
_player.updateFrame();
_player._visible3 = _player._visible;
_player._special = _scene.getDepthHighBits(_player._playerPos);
_player._priorTimer = _scene._frameStartTime - _player._ticksAmount;

View File

@ -235,15 +235,15 @@ void Player::updateFrame() {
}
// Set the player frame number
int frameIndex = ABS(_frameListIndex);
_frameNumber = (_frameListIndex <= 0) ? spriteSet._charInfo->_frameList[frameIndex] :
spriteSet._charInfo->_frameList2[frameIndex];
int listIndex = ABS(_frameListIndex);
_frameNumber = (_frameListIndex >= 0) ? spriteSet._charInfo->_startFrames[listIndex] :
spriteSet._charInfo->_stopFrames[listIndex];
// Set next waiting period in ticks
if (frameIndex == 0) {
if (listIndex == 0) {
setBaseFrameRate();
} else {
_ticksAmount = spriteSet._charInfo->_ticksList[frameIndex];
_ticksAmount = spriteSet._charInfo->_ticksList[listIndex];
}
}
@ -521,11 +521,11 @@ void Player::idle() {
_frameNumber += direction;
_forceRefresh = true;
if (spriteSet._charInfo->_frameList2[frameIndex] < _frameNumber) {
if (spriteSet._charInfo->_stopFrames[frameIndex] < _frameNumber) {
_trigger = _upcomingTrigger;
updateFrame();
}
if (spriteSet._charInfo->_frameList[frameIndex] < _frameNumber) {
if (spriteSet._charInfo->_startFrames[frameIndex] < _frameNumber) {
_trigger = _upcomingTrigger;
updateFrame();
}

View File

@ -172,6 +172,9 @@ public:
* direction which the player is facing in) */
void selectSeries();
/*
* Moves to the next frame for the currently active player sprite set
*/
void updateFrame();
void update();