Still working on some VN elements, it's coming together slowly.
This commit is contained in:
@ -15,6 +15,16 @@
|
||||
*/
|
||||
#define easeTimeToEase(start, current, duration) ((current-start)/duration)
|
||||
|
||||
/**
|
||||
* Animation tool for converting 0-1 space into a 0-0.5 back to zero space. This
|
||||
* is intended to make a "Forward then backwards" effect for animation. This
|
||||
* method will not scale t.
|
||||
* @param t Time in space to back and fourth on between 0 and 1.
|
||||
* @returns Forward and backwards time. 0 to 0.5 are as such, 0.5 to 1 are from
|
||||
* 0.5 to 0.
|
||||
*/
|
||||
#define easeTimeToForwardAndBackward(t) (t < 0.5 ? t : 1 - t)
|
||||
|
||||
// Easing Functions, most were sourced from https://gist.github.com/gre/1650294
|
||||
#define easeLinear(t) t
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "../../libs.h"
|
||||
|
||||
/** Maximum number of actions a timeline can support, smaller than 0xFF */
|
||||
#define TIMELINE_ACTION_COUNT_MAX 32
|
||||
#define TIMELINE_ACTION_COUNT_MAX 128
|
||||
|
||||
/** Type forwarders */
|
||||
typedef struct _timeline_t timeline_t;
|
||||
|
@ -7,22 +7,44 @@
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "math.h"
|
||||
|
||||
/**
|
||||
* Generate a number between 0 and max. (max exclusive)
|
||||
*
|
||||
* @param max Max number to generate
|
||||
* @return Number between 0 and max.
|
||||
* Generates a random int32_t.
|
||||
* @returns A random int32_t number.
|
||||
*/
|
||||
#define u32rand(max) (rand()%max)
|
||||
#define u8rand(max) (uint8_t)u23rand(max)
|
||||
#define randInt32() ((int32_t)rand())
|
||||
|
||||
/**
|
||||
* Generate a number between min and max. (max exclusive, min inclusive)
|
||||
*
|
||||
* @param min Min number to generate.
|
||||
* @param max Max number to generate.
|
||||
* @return Number between min and max.
|
||||
* Generates a random floating point number.
|
||||
* @returns A random floating point number.
|
||||
*/
|
||||
#define u32randRange(min, max) (u32rand(max-min)+min)
|
||||
#define u8randRange(min, max) (uint8_t)u32randRange(min,max)
|
||||
#define randFloat() (((float)randInt32()) * M_PI)
|
||||
|
||||
/**
|
||||
* Generates a random uint32_t
|
||||
* @returns A random uint32_t number.
|
||||
*/
|
||||
#define randUint32() (uint32_t)randInt32()
|
||||
|
||||
/**
|
||||
* Generates a random uint8_t
|
||||
* @returns A random uint8_t number.
|
||||
*/
|
||||
#define randUint8() (uint8_t)randInt32()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Clamps a random number generation.
|
||||
* @param n Number that has been generated from the random.
|
||||
* @param min Minimum value to generate from. (Inclusive)
|
||||
* @param max Maximum value to generate to. (Exclusive)
|
||||
* @return Random number between min and max.
|
||||
*/
|
||||
#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 randUint32Range(min, max) randRange(randUint32(), min, max)
|
||||
#define randUint8Range(min, max) randRange(randUint8(), min, max)
|
@ -11,21 +11,27 @@
|
||||
#include "../display/primitive.h"
|
||||
#include "../display/tileset.h"
|
||||
|
||||
#define VNCHARACTER_EMOTION_NEUTRAL 0x00
|
||||
#define VN_CHARACTER_BLINK_TIME_RANGE_MAX 6
|
||||
#define VN_CHARACTER_SIZE 0.5
|
||||
|
||||
typedef struct {
|
||||
float x, y, z;
|
||||
float yaw, pitch, roll;
|
||||
float scaleX, scaleY;
|
||||
|
||||
uint8_t emotion;
|
||||
bool talking;
|
||||
float blinkStart;
|
||||
|
||||
float t;
|
||||
tileset_t tilesetEyes;
|
||||
tileset_t tilesetMouth;
|
||||
|
||||
texture_t *textureEyes;
|
||||
texture_t *textureBody;
|
||||
texture_t *textureMouth;
|
||||
texture_t *textureFace;
|
||||
|
||||
primitive_t primitive;
|
||||
primitive_t primitiveEyes;
|
||||
primitive_t primitiveBody;
|
||||
primitive_t primitiveMouth;
|
||||
primitive_t primitiveFace;
|
||||
} vncharacter_t;
|
@ -11,10 +11,24 @@
|
||||
|
||||
#define VN_CONVERSATION_TEXT_COUNT_MAX 32
|
||||
|
||||
#define VN_CONVERSATION_TYPE_DELAY 0x01
|
||||
#define VN_CONVERSATION_TYPE_TEXT 0x02
|
||||
// Type Forwarders
|
||||
|
||||
typedef struct _vnconversationtext_t vnconversationtext_t;
|
||||
typedef struct _vnconversation_t vnconversation_t;
|
||||
|
||||
/**
|
||||
* Callback for conversation text events.
|
||||
* @param conversation Conversation this text is attached to.
|
||||
* @param text Text item that is being used in the callback
|
||||
*/
|
||||
typedef void vnconversationcallback_t(vnconversation_t *conversation,
|
||||
vnconversationtext_t *text
|
||||
);
|
||||
|
||||
typedef struct _vnconversationtext_t {
|
||||
/** Pointer to any custom user data for this text action. */
|
||||
void *data;
|
||||
|
||||
typedef struct {
|
||||
/** Conversation Type to decide what this data is used for */
|
||||
uint8_t type;
|
||||
|
||||
@ -23,15 +37,32 @@ typedef struct {
|
||||
|
||||
/** Time in seconds to delay if type is delay */
|
||||
float delay;
|
||||
|
||||
/** Callback to fire the moment the text is active in the conversation */
|
||||
vnconversationcallback_t *onStart;
|
||||
|
||||
/** Callback to fire every update tick of this conversation element */
|
||||
vnconversationcallback_t *onUpdate;
|
||||
|
||||
/** Callback to fire when this conversation element is ended */
|
||||
vnconversationcallback_t *onEnd;
|
||||
} vnconversationtext_t;
|
||||
|
||||
typedef struct {
|
||||
/** Representation of a conversation, laid out similarly to a timeline. */
|
||||
typedef struct _vnconversation_t {
|
||||
/** Internal Textbox for text elements */
|
||||
vntextbox_t textbox;
|
||||
vnconversationtext_t texts[VN_CONVERSATION_TEXT_COUNT_MAX];
|
||||
|
||||
/** Array of text elements */
|
||||
vnconversationtext_t texts[VN_CONVERSATION_TEXT_COUNT_MAX];
|
||||
uint8_t textCount;
|
||||
|
||||
/** Internal timeline tracking */
|
||||
float timeline;
|
||||
|
||||
/** When the current text was first attached */
|
||||
float delayStart;
|
||||
|
||||
uint8_t textCount;
|
||||
/** Current index within the array of texts that is currently processing */
|
||||
uint8_t textCurrent;
|
||||
} vnconversation_t;
|
Reference in New Issue
Block a user