more construct(char* args) for kaos constructors

This commit is contained in:
Iris Lightshard 2019-03-05 18:01:45 -08:00
parent ffde2dc832
commit a99cabc018
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
2 changed files with 13 additions and 2 deletions

13
Kaos.c
View file

@ -60,11 +60,22 @@ void deleteConversation(Kaos* target)
free(target);
}
Kaos* newChoice(char* q, char* a1, char* a2, HyperKaos* p1, HyperKaos* p2)
Kaos* newChoice(char* args)
{
char q[32], a1[32], a2[32];
int p1, p2;
Kaos* core = rawKaos();
Choice* self = malloc(sizeof(Choice));
if (sscanf(args, "q %[^,], a1 %[^,], a2 %[^,], p1 %d, p2 %d", q, a1, a2, &p1, &p2) != 5)
{
free(core);
free(self);
self = NULL;
core = NULL;
return core;
}
self->question = TTF_RenderText_Solid(font, q, textColor);
self->answ1 = TTF_RenderText_Solid(font, a1, textColor);
self->answ2 = TTF_RenderText_Solid(font, a2, textColor);

2
Kaos.h
View file

@ -95,7 +95,7 @@ Kaos* newConversation(char* args);
void runConversation(Kaos* self);
void deleteConversation(Kaos* target);
Kaos* newChoice(char* q, char* a1, char* a2, HyperKaos* p1, HyperKaos* p2);
Kaos* newChoice(char* args);
void runChoice(Kaos* self);
void deleteChoice(Kaos* target);