diff --git a/src/game/poker/characters/jenny.c b/src/game/poker/characters/jenny.c index 6dd83622..d53d39fa 100644 --- a/src/game/poker/characters/jenny.c +++ b/src/game/poker/characters/jenny.c @@ -23,4 +23,6 @@ void pokerCharacterJennyInit(vncharacter_t *vnc) { 608, 250, 280, 123 ); + + vnc->breathing = false; } diff --git a/src/game/poker/characters/julie.c b/src/game/poker/characters/julie.c index a085002f..1e72cb6c 100644 --- a/src/game/poker/characters/julie.c +++ b/src/game/poker/characters/julie.c @@ -12,19 +12,19 @@ void pokerCharacterJulieInit(vncharacter_t *vnc) { vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 1053, 1961); // Layers - vnCharacterLayerAdd(vnc, 4, + vnc->layerEyes = vnCharacterLayerAdd(vnc, 4, 1053, 0, 353, 119, 344, 351 ); - vnCharacterLayerAdd(vnc, 12, + vnc->layerMouth = vnCharacterLayerAdd(vnc, 12, 1053, 351, 353, 119, 344, 351 ); - vnCharacterLayerAdd(vnc, 4, + vnc->layerEyebrows = vnCharacterLayerAdd(vnc, 4, 1053, 702, 353, 119, 344, 351 diff --git a/src/game/poker/characters/lucy.c b/src/game/poker/characters/lucy.c index 3e3652a3..9dfecc6f 100644 --- a/src/game/poker/characters/lucy.c +++ b/src/game/poker/characters/lucy.c @@ -13,20 +13,19 @@ void pokerCharacterLucyInit(vncharacter_t *vnc) { vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 1440, 2240); // Layers - - vnCharacterLayerAdd(vnc, 5, + vnc->layerEyes = vnCharacterLayerAdd(vnc, 5, 1440, 0, 675, 327, 295, 235 ); - vnCharacterLayerAdd(vnc, 12, + vnc->layerMouth = vnCharacterLayerAdd(vnc, 12, 1440, 235, 675, 327, 295, 235 ); - vnCharacterLayerAdd(vnc, 5, + vnc->layerEyebrows = vnCharacterLayerAdd(vnc, 5, 1440, 470, 675, 327, 295, 235 diff --git a/src/game/poker/characters/penny.c b/src/game/poker/characters/penny.c index de77581f..fb7f58fa 100644 --- a/src/game/poker/characters/penny.c +++ b/src/game/poker/characters/penny.c @@ -12,19 +12,19 @@ void pokerCharacterPennyInit(vncharacter_t *vnc) { vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 1000, 1920); // Layers - vnCharacterLayerAdd(vnc, 5, + vnc->layerEyebrows = vnCharacterLayerAdd(vnc, 5, 1000, 0, 367, 256, 280, 280 ); - vnCharacterLayerAdd(vnc, 4, + vnc->layerEyes = vnCharacterLayerAdd(vnc, 4, 1000, 280, 367, 256, 280, 280 ); - vnCharacterLayerAdd(vnc, 12, + vnc->layerMouth = vnCharacterLayerAdd(vnc, 12, 1000, 560, 367, 256, 280, 280 diff --git a/src/game/poker/characters/sammy.c b/src/game/poker/characters/sammy.c index 5c662350..22353a34 100644 --- a/src/game/poker/characters/sammy.c +++ b/src/game/poker/characters/sammy.c @@ -12,19 +12,19 @@ void pokerCharacterSammyInit(vncharacter_t *vnc) { vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, 731, 2122); // Layers - vnCharacterLayerAdd(vnc, 4, + vnc->layerEyes = vnCharacterLayerAdd(vnc, 4, 731, 0, 215, 264, 307, 213 ); - vnCharacterLayerAdd(vnc, 12, + vnc->layerMouth = vnCharacterLayerAdd(vnc, 12, 731, 213, 215, 264, 307, 213 ); - vnCharacterLayerAdd(vnc, 5, + vnc->layerEyebrows = vnCharacterLayerAdd(vnc, 5, 731, 426, 215, 264, 307, 213 diff --git a/src/game/poker/game.c b/src/game/poker/game.c index 4fcc8e1f..5a5fa963 100644 --- a/src/game/poker/game.c +++ b/src/game/poker/game.c @@ -43,7 +43,6 @@ void pokerGameUpdate(pokergame_t *game) { game->poker.players ); - // Bind the shader. shaderUse(&game->assets.shader); diff --git a/src/util/rand.h b/src/util/rand.h index 47ca5bdf..f43d2521 100644 --- a/src/util/rand.h +++ b/src/util/rand.h @@ -51,6 +51,6 @@ #define randRange(n, min, max) (mathMod(n, (max-min)) + min) #define randInt32Range(min, max) randRange(randInt32(), min, max) -#define randFloatRange(min, max) (fmod(randFloat(), max- min) + min) +#define randFloatRange(min, max) ((float)fmod(randFloat(), max- min) + min) #define randUint32Range(min, max) randRange(randUint32(), min, max) #define randUint8Range(min, max) randRange(randUint8(), min, max) \ No newline at end of file diff --git a/src/vn/vncharacter.c b/src/vn/vncharacter.c index 388075ca..54c4c8c9 100644 --- a/src/vn/vncharacter.c +++ b/src/vn/vncharacter.c @@ -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; + } } diff --git a/src/vn/vncharacter.h b/src/vn/vncharacter.h index 15238922..ece06dd3 100644 --- a/src/vn/vncharacter.h +++ b/src/vn/vncharacter.h @@ -17,10 +17,11 @@ #include "../display/animation/easing.h" #define VN_CHARACTER_BLINK_TIME_RANGE_MAX 6 +#define VN_CHARACTER_BLINK_SPEED 3.0f #define VN_CHARACTER_LAYERS_MAX 6 typedef struct { - int32_t lx, ly, x, y, width, height; + int16_t lx, ly, x, y, width, height; uint8_t frames; } vncharacterlayer_t; @@ -35,18 +36,24 @@ typedef struct { /** Texture sheet for the character */ texture_t *texture; - /** Count of layers */ + /** Layer Information */ vncharacterlayer_t layers[VN_CHARACTER_LAYERS_MAX]; uint8_t layerCount; + uint8_t layerEyes; + uint8_t layerMouth; + uint8_t layerEyebrows; + + bool breathing; + float blinkStart; } vncharacter_t; void vnCharacterInit(vncharacter_t *character, texture_t *texture); uint8_t vnCharacterLayerAdd(vncharacter_t *character, uint8_t frames, - int32_t lx, int32_t ly, - int32_t x, int32_t y, - int32_t width, int32_t height + int16_t lx, int16_t ly, + int16_t x, int16_t y, + int16_t width, int16_t height ); void vnCharacterLayerSetFrame(vncharacter_t *character, uint8_t l, uint8_t f);