fixed: sprite hittest, speech draws in screen bounds

svn-id: r17635
This commit is contained in:
Andrew Kurushin 2005-04-16 16:55:35 +00:00
parent 7b9a3b1fa7
commit bffeb58d06
4 changed files with 13 additions and 38 deletions

View File

@ -739,6 +739,12 @@ void Actor::handleSpeech(int msec) {
actor->currentAction = kActionSpeak;
actor->actionCycle = _vm->_rnd.getRandomNumber(63);
}
for (i = 0; i < _activeSpeech.actorsCount; i++) {
actor = getActor(_activeSpeech.actorIds[i]);
_activeSpeech.speechCoords[i] = actor->screenPosition;
_activeSpeech.speechCoords[i].y -= ACTOR_DIALOGUE_HEIGHT;
_activeSpeech.speechCoords[i].y = MAX(_activeSpeech.speechCoords[i].y, (int16)10);
}
}
_activeSpeech.playing = true;
return;
@ -770,15 +776,6 @@ void Actor::handleSpeech(int msec) {
_activeSpeech.strings[i - 1] = _activeSpeech.strings[i];
}
_activeSpeech.stringsCount--;
if (_activeSpeech.stringsCount > 0 && _activeSpeech.actorIds[0] != 0) {
// Update actor speech position for the next string.
// Note that we only need to do this for the first
// actor since simultaneous speech is never more than
// one string at a time.
actor = getActor(_activeSpeech.actorIds[0]);
_activeSpeech.speechCoords[0] = actor->screenPosition;
_activeSpeech.speechCoords[0].y -= ACTOR_DIALOGUE_HEIGHT;
}
}
if (!isSpeaking())
@ -1280,7 +1277,7 @@ int Actor::drawActors() {
}
// draw speeches
if (isSpeaking() && !_vm->_script->_skipSpeeches) {
if (isSpeaking() && _activeSpeech.playing && !_vm->_script->_skipSpeeches) {
int i;
int textDrawFlags;
char oneChar[2];
@ -1699,12 +1696,11 @@ void Actor::actorSpeech(uint16 actorId, const char **strings, int stringsCount,
for (i = 0; i < stringsCount; i++) {
_activeSpeech.strings[i] = strings[i];
}
_activeSpeech.stringsCount = stringsCount;
_activeSpeech.speechFlags = speechFlags;
_activeSpeech.actorsCount = 1;
_activeSpeech.actorIds[0] = actorId;
_activeSpeech.speechCoords[0] = actor->screenPosition;
_activeSpeech.speechCoords[0].y -= ACTOR_DIALOGUE_HEIGHT;
_activeSpeech.speechColor[0] = actor->speechColor;
_activeSpeech.outlineColor[0] = kITEColorBlack;
_activeSpeech.sampleResourceId = sampleResourceId;
@ -1746,8 +1742,6 @@ void Actor::simulSpeech(const char *string, uint16 *actorIds, int actorIdsCount,
actor = getActor(actorIds[i]);
_activeSpeech.actorIds[i] = actorIds[i];
_activeSpeech.speechCoords[i] = actor->screenPosition;
_activeSpeech.speechCoords[i].y -= ACTOR_DIALOGUE_HEIGHT;
_activeSpeech.speechColor[i] = actor->speechColor;
_activeSpeech.outlineColor[i] = 0; // disable outline
}

View File

@ -512,7 +512,7 @@ private:
void sfResumeBgdAnim(SCRIPTFUNC_PARAMS);
void SF_throwActor(SCRIPTFUNC_PARAMS);
void sfWaitWalk(SCRIPTFUNC_PARAMS);
void SF_sceneID(SCRIPTFUNC_PARAMS);
void sfScriptSceneID(SCRIPTFUNC_PARAMS);
void SF_changeActorScene(SCRIPTFUNC_PARAMS);
void SF_climb(SCRIPTFUNC_PARAMS);
void sfSetDoorState(SCRIPTFUNC_PARAMS);

View File

@ -104,7 +104,7 @@ void Script::setupScriptFuncList(void) {
OPCODE(sfResumeBgdAnim),
OPCODE(SF_throwActor),
OPCODE(sfWaitWalk),
OPCODE(SF_sceneID),
OPCODE(sfScriptSceneID),
OPCODE(SF_changeActorScene),
OPCODE(SF_climb),
OPCODE(sfSetDoorState),
@ -1346,7 +1346,7 @@ void Script::sfWaitWalk(SCRIPTFUNC_PARAMS) {
}
// Script function #54 (0x36)
void Script::SF_sceneID(SCRIPTFUNC_PARAMS) {
void Script::sfScriptSceneID(SCRIPTFUNC_PARAMS) {
thread->_returnValue = _vm->_scene->currentSceneNumber();
}

View File

@ -241,8 +241,6 @@ bool Sprite::hitTest(SpriteList &spriteList, int spriteNumber, const Point &scre
const byte *spriteBuffer;
int i, j;
const byte *srcRowPointer;
int clipWidth;
int clipHeight;
int width;
int height;
int xAlign;
@ -255,27 +253,10 @@ bool Sprite::hitTest(SpriteList &spriteList, int spriteNumber, const Point &scre
spritePointer.x = screenCoord.x + xAlign;
spritePointer.y = screenCoord.y + yAlign;
if (spritePointer.x < 0) {
if ((testPoint.y < spritePointer.y) || (testPoint.y >= spritePointer.y + height)) {
return false;
}
if (spritePointer.y < 0) {
return false;
}
clipWidth = width;
if (width > (_vm->getDisplayWidth() - spritePointer.x)) {
clipWidth = (_vm->getDisplayWidth() - spritePointer.x);
}
clipHeight = height;
if (height > (_vm->getDisplayHeight() - spritePointer.y)) {
clipHeight = (_vm->getDisplayHeight() - spritePointer.y);
}
if ((testPoint.y < spritePointer.y) || (testPoint.y >= spritePointer.y + clipHeight)) {
return false;
}
if ((testPoint.x < spritePointer.x) || (testPoint.x >= spritePointer.x + clipWidth)) {
if ((testPoint.x < spritePointer.x) || (testPoint.x >= spritePointer.x + width)) {
return false;
}
i = testPoint.y - spritePointer.y;