Added the dealer proper.

This commit is contained in:
2021-08-23 09:29:53 -07:00
parent fefa044145
commit a65ae99840
15 changed files with 244 additions and 75 deletions

View File

@ -14,9 +14,9 @@ void vnCharacterInit(
int32_t faceX, int32_t faceY,
int32_t faceWidth, int32_t faceHeight
) {
character->x = 0.5f;
character->y = -1.17f;
character->z = -0.35f;
character->x = 0;
character->y = -2.2f;
character->z = -0.3f;
character->yaw = 0;
character->pitch = 0;
@ -26,16 +26,9 @@ void vnCharacterInit(
character->scaleY = 1;
character->texture = texture;
character->talking = true;
character->talking = false;
character->blinkStart = 0;
// Init the primitive.
primitiveInit(&character->primitive,
QUAD_VERTICE_COUNT * VN_CHARACTER_QUAD_COUNT,
QUAD_INDICE_COUNT * VN_CHARACTER_QUAD_COUNT
);
character->baseWidth = baseWidth;
character->baseHeight = baseHeight;
character->faceX = faceX;
@ -43,13 +36,21 @@ void vnCharacterInit(
character->faceWidth = faceWidth;
character->faceHeight = faceHeight;
character->emotion = VN_CHARACTER_EMOTION_HAPPY;
// Init the primitive.
primitiveInit(&character->primitive,
QUAD_VERTICE_COUNT * VN_CHARACTER_QUAD_COUNT,
QUAD_INDICE_COUNT * VN_CHARACTER_QUAD_COUNT
);
// Buffer the base quad, this never changes (currently)
_vnCharacterBuffer(character,
0, 0, baseWidth, baseHeight, 0, 0, 0
);
_vnCharacterFaceBuffer(character, 0, 0, VN_CHARACTER_QUAD_EYEBROWS);
_vnCharacterFaceBuffer(character, 0, 1, VN_CHARACTER_QUAD_EYES);
_vnCharacterFaceBuffer(character, 0, 2, VN_CHARACTER_QUAD_MOUTH);
_vnCharacterFaceBuffer(character, 0, VN_CHARACTER_QUAD_EYEBROWS);
_vnCharacterFaceBuffer(character, 0, VN_CHARACTER_QUAD_EYES);
_vnCharacterFaceBuffer(character, 0, VN_CHARACTER_QUAD_MOUTH);
}
void _vnCharacterBuffer(vncharacter_t *character,
@ -77,63 +78,78 @@ void _vnCharacterBuffer(vncharacter_t *character,
}
void _vnCharacterFaceBuffer(vncharacter_t *character,
int32_t col, int32_t row, int32_t i
int32_t col, int32_t i
) {
_vnCharacterBuffer(character,
character->faceX, character->faceY,
character->faceWidth, character->faceHeight,
character->baseWidth + (character->faceWidth * col),
character->faceHeight * row,
character->faceHeight * (i -1),
i
);
}
void vnCharacterUpdate(vncharacter_t *character, engine_t *engine) {
float n;
uint8_t eyes, mouth, eyebrows;
float t;
// Update the blinking frames
n = (engine->time.current - character->blinkStart) * 3.0f;
if(n > 1.0f) {
character->blinkStart = engine->time.current + randFloatRange(
1, VN_CHARACTER_BLINK_TIME_RANGE_MAX
);
} else if(n > 0) {
n = easeInQuad(easeTimeToForwardAndBackward(n) * 4);
_vnCharacterFaceBuffer(character,
(int32_t)n, 1, VN_CHARACTER_QUAD_EYES
);
}
// Setup frames based on the emotion.
mouth = character->emotion % 0x04;
eyes = (character->emotion/0x04) % 0x04;
eyebrows = ((character->emotion/0x04)/0x04) % 0x05;
// Updating the talking frames
_vnCharacterFaceBuffer(character, eyebrows, VN_CHARACTER_QUAD_EYEBROWS);
_vnCharacterFaceBuffer(character, eyes, VN_CHARACTER_QUAD_EYES);
mouth *= VN_CHARACTER_TALKING_FRAME_COUNT;
if(character->talking) {
n = easeTimeToForwardAndBackward(fmod(engine->time.current * 1.6, 1)) * 6;
_vnCharacterFaceBuffer(character,
(int32_t)n, 2, VN_CHARACTER_QUAD_MOUTH
);
} else {
_vnCharacterFaceBuffer(character,
0, 2, VN_CHARACTER_QUAD_MOUTH
);
t = animForwardAndBackwardScaled(mathModFloat(
engine->time.current * animTimeScaleFromFrameTime(3, 0.2f), 1.0f
));
mouth += (uint8_t)(t * VN_CHARACTER_TALKING_FRAME_COUNT);
}
_vnCharacterFaceBuffer(character, mouth, VN_CHARACTER_QUAD_MOUTH);
// Update the scale frames for talking/breathing
// float n;
// // Update the blinking frames
// n = (engine->time.current - character->blinkStart) * 3.0f;
// if(n > 1.0f) {
// character->blinkStart = engine->time.current + randFloatRange(
// 1, VN_CHARACTER_BLINK_TIME_RANGE_MAX
// );
// } else if(n > 0) {
// n = easeInQuad(easeTimeToForwardAndBackward(n) * 4);
// _vnCharacterFaceBuffer(character,
// (int32_t)n, 1, VN_CHARACTER_QUAD_EYES
// );
// }
// if(character->talking) {
// n = easeTimeToForwardAndBackward(
// mathModFloat(engine->time.current * 1.6, 1)
// ) * 6.0f;
// _vnCharacterFaceBuffer(character,
// (int32_t)n, 2, VN_CHARACTER_QUAD_MOUTH
// );
// } else {
// _vnCharacterFaceBuffer(character,
// 0, 2, VN_CHARACTER_QUAD_MOUTH
// );
// }
// Update the scale frames for breathing / talk breathing
float speed, amount;
if(character->talking) {
speed = 1.0f;
amount = 400.0f;
} else {
speed = 0.4f;
amount = 400.0f;
// n = easeTimeToForwardAndBackward(fmod(engine->time.current, speed) / speed)*2;
// n = easeInOutCubic(n) / amount - (1/(amount*2));
// character->scaleX = 1 + n;
// character->scaleY = 1 + n*2;
}
n = easeTimeToForwardAndBackward(fmod(engine->time.current, 1 / speed) * speed) * 2.0f;
n = easeInOutQuad(n) / amount - (1/(amount*2));
character->scaleX = 1 + n;
character->scaleY = 1 - n;
speed = 0.2f;
amount = 300.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;
}
void vnCharacterRender(vncharacter_t *character, shader_t *shader) {