Restoring blinking
This commit is contained in:
@ -7,7 +7,6 @@
|
||||
|
||||
#include "vncharacter.h"
|
||||
|
||||
|
||||
void vnCharacterInit(vncharacter_t *character, texture_t *texture) {
|
||||
character->x = 0;
|
||||
character->y = 0;
|
||||
@ -22,6 +21,12 @@ void vnCharacterInit(vncharacter_t *character, texture_t *texture) {
|
||||
character->layerCount = 0;
|
||||
character->texture = texture;
|
||||
|
||||
character->layerEyes = 0xFF;
|
||||
character->layerMouth = 0xFF;
|
||||
character->layerEyebrows = 0xFF;
|
||||
character->breathing = true;
|
||||
character->blinkStart = 0;
|
||||
|
||||
// Init the primitive.
|
||||
primitiveInit(&character->primitive,
|
||||
QUAD_VERTICE_COUNT * VN_CHARACTER_LAYERS_MAX,
|
||||
@ -30,10 +35,25 @@ void vnCharacterInit(vncharacter_t *character, texture_t *texture) {
|
||||
}
|
||||
|
||||
void vnCharacterUpdate(vncharacter_t *character, engine_t *engine) {
|
||||
float t;
|
||||
float t, n;
|
||||
float speed, amount;
|
||||
|
||||
// Setup frames based on the emotion.
|
||||
if(character->layerEyes != 0xFF) {
|
||||
n = (engine->time.current-character->blinkStart)*VN_CHARACTER_BLINK_SPEED;
|
||||
if(n > 1.0f) {
|
||||
character->blinkStart = engine->time.current + randFloatRange(
|
||||
1, VN_CHARACTER_BLINK_TIME_RANGE_MAX
|
||||
);
|
||||
} else if(n > 0) {
|
||||
n = (
|
||||
easeInQuad(animForwardAndBackwardScaled(n)) *
|
||||
character->layers[character->layerEyes].frames
|
||||
);
|
||||
vnCharacterLayerSetFrame(character, character->layerEyes, (int32_t)n);
|
||||
}
|
||||
}
|
||||
|
||||
// mouth = character->emotion % 0x04;
|
||||
// eyes = (character->emotion/0x04) % 0x04;
|
||||
// eyebrows = ((character->emotion/0x04)/0x04) % 0x05;
|
||||
@ -76,14 +96,19 @@ void vnCharacterUpdate(vncharacter_t *character, engine_t *engine) {
|
||||
// }
|
||||
|
||||
// Update the scale frames for breathing / talk breathing
|
||||
speed = 0.2f;
|
||||
amount = 90.0f;
|
||||
t = animForwardAndBackwardScaled(
|
||||
mathModFloat(engine->time.current, 1 / speed) * speed
|
||||
);
|
||||
t = easeInOutQuad(t) / amount - (1/(amount*2));
|
||||
character->scaleX = 1 + t;
|
||||
character->scaleY = 1 - t;
|
||||
if(character->breathing) {
|
||||
speed = 0.2f;
|
||||
amount = 90.0f;
|
||||
t = animForwardAndBackwardScaled(
|
||||
mathModFloat(engine->time.current, 1 / speed) * speed
|
||||
);
|
||||
t = easeInOutQuad(t) / amount - (1/(amount*2));
|
||||
character->scaleX = 1 + t;
|
||||
character->scaleY = 1 - t;
|
||||
} else {
|
||||
character->scaleX = 1;
|
||||
character->scaleY = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user