wlh jsplu
This commit is contained in:
parent
07476e1a9c
commit
fbcfc338b2
19
histoire.h
19
histoire.h
|
@ -16,11 +16,11 @@ typedef enum PersonneId {
|
||||||
#define MAX_PERSONNE 5
|
#define MAX_PERSONNE 5
|
||||||
int personne_idx = 0;
|
int personne_idx = 0;
|
||||||
Personne personnes[MAX_PERSONNE] = {
|
Personne personnes[MAX_PERSONNE] = {
|
||||||
[0] = { .name = "Viola" },
|
[VIOLA] = { .name = "Viola" },
|
||||||
[1] = { .name = "Archie" },
|
[ARCHIE] = { .name = "Archie" },
|
||||||
[2] = { .name = "Minuit" },
|
[MINUIT] = { .name = "Minuit" },
|
||||||
[3] = { .name = "Phillip" },
|
[PHILLIP] = { .name = "Phillip" },
|
||||||
[4] = { .name = "Ed" },
|
[ED] = { .name = "Ed" },
|
||||||
};
|
};
|
||||||
|
|
||||||
void init_personnes(void)
|
void init_personnes(void)
|
||||||
|
@ -54,6 +54,15 @@ typedef struct Histoire {
|
||||||
Branche branches[NB_BRANCHE];
|
Branche branches[NB_BRANCHE];
|
||||||
} Histoire;
|
} Histoire;
|
||||||
|
|
||||||
|
typedef struct Historique {
|
||||||
|
int idx_branche;
|
||||||
|
int branche[NB_BRANCHE];
|
||||||
|
int idx_conv;
|
||||||
|
int conversation[NB_CONVERSATION_MAX];
|
||||||
|
} Historique;
|
||||||
|
|
||||||
|
Historique historique = {0};
|
||||||
|
|
||||||
Histoire histoire = {
|
Histoire histoire = {
|
||||||
.nb_branche = 3,
|
.nb_branche = 3,
|
||||||
.branches = {
|
.branches = {
|
||||||
|
|
41
main.c
41
main.c
|
@ -10,6 +10,8 @@ int horloge_min = 9;
|
||||||
|
|
||||||
#include "histoire.h"
|
#include "histoire.h"
|
||||||
|
|
||||||
|
float timer = 0.0f;
|
||||||
|
|
||||||
#define CHOIX_PAD 2
|
#define CHOIX_PAD 2
|
||||||
#define CHOIX_COLOR WHITE
|
#define CHOIX_COLOR WHITE
|
||||||
#define CHOIX_COLOR_HOVER LIGHTGRAY
|
#define CHOIX_COLOR_HOVER LIGHTGRAY
|
||||||
|
@ -187,15 +189,20 @@ int main()
|
||||||
|
|
||||||
Texture phone_battery_tex = LoadTexture("data/phone-battery.png");
|
Texture phone_battery_tex = LoadTexture("data/phone-battery.png");
|
||||||
Texture left_arrow_tex = LoadTexture("data/left-arrow.png");
|
Texture left_arrow_tex = LoadTexture("data/left-arrow.png");
|
||||||
|
|
||||||
init_personnes();
|
init_personnes();
|
||||||
|
|
||||||
|
historique.idx_branche = 1;
|
||||||
|
historique.branche[0] = 0;
|
||||||
|
historique.conversation[0] = 0;
|
||||||
|
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) {
|
||||||
if (IsWindowResized()) {
|
if (IsWindowResized()) {
|
||||||
window.x = GetScreenWidth();
|
window.x = GetScreenWidth();
|
||||||
window.y = GetScreenHeight();
|
window.y = GetScreenHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer += GetFrameTime();
|
||||||
|
|
||||||
Rectangle phone_box = {
|
Rectangle phone_box = {
|
||||||
window.x/2-window.y/3, 0,
|
window.x/2-window.y/3, 0,
|
||||||
window.y/3*2, window.y,
|
window.y/3*2, window.y,
|
||||||
|
@ -226,6 +233,31 @@ int main()
|
||||||
}, 0, phone_battery_scale, WHITE
|
}, 0, phone_battery_scale, WHITE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Branche branche = histoire.branches[historique.branche[historique.idx_branche-1]];
|
||||||
|
Conversation conv = branche.conversations[historique.conversation[historique.idx_conv-1]];
|
||||||
|
|
||||||
|
personnes[branche.personne].message = conv.question;
|
||||||
|
|
||||||
|
if (!personnes[branche.personne].active && timer > conv.read_time) {
|
||||||
|
personnes[branche.personne].active = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_SPACE)) {
|
||||||
|
printf("idx branche = %d\n", historique.idx_branche);
|
||||||
|
printf("idx conv = %d\n", historique.idx_conv);
|
||||||
|
historique.idx_conv++;
|
||||||
|
historique.conversation[historique.idx_conv] = 0; // idx de la reponse
|
||||||
|
if (historique.idx_conv >= branche.nb_conversation) {
|
||||||
|
historique.idx_conv = 0;
|
||||||
|
historique.idx_branche++;
|
||||||
|
historique.branche[historique.idx_branche] =
|
||||||
|
historique.branche[historique.idx_branche-1]+1;
|
||||||
|
if (historique.idx_branche > histoire.nb_branche) {
|
||||||
|
printf("fin du monde\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int choix_active = 0;
|
static int choix_active = 0;
|
||||||
if (!choix_active) {
|
if (!choix_active) {
|
||||||
float size = header_box.height*0.42;
|
float size = header_box.height*0.42;
|
||||||
|
@ -321,9 +353,14 @@ int main()
|
||||||
case 3: r = draw_4_choix(choix_box, "choix 1", "choix 2", "choix 3", "choix 4"); break;
|
case 3: r = draw_4_choix(choix_box, "choix 1", "choix 2", "choix 3", "choix 4"); break;
|
||||||
}
|
}
|
||||||
if (r) printf("%d\n", r);
|
if (r) printf("%d\n", r);
|
||||||
|
|
||||||
|
if (timer > conv.read_time) {
|
||||||
|
DrawText(conv.question, 500, 500, 50, ORANGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawFPS(0,0);
|
DrawFPS(window.x - 100, 10);
|
||||||
|
DrawText(TextFormat("timer = %.01f", timer), 5, 25, 25, WHITE);
|
||||||
}
|
}
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue