hyperkaos/HyperKaos.c

107 lines
No EOL
1.7 KiB
C

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include "SDL/SDL_mixer.h"
#include "enum.h"
#include "Kaos.h"
#include "HyperKaos.h"
typedef struct room Room;
typedef struct player Player;
typedef struct timer Timer;
typedef struct textBox TextBox;
typedef struct scene Scene;
#include "extern.h"
HyperKaos* newHyperKaos(int id, int type, int x, int y, int w, int h)
{
HyperKaos* self = malloc(sizeof(HyperKaos));
self->domain.x = x;
self->domain.y = y;
self->domain.w = w;
self->domain.h = h;
self->kaosID = id;
self->eventType = type;
self->head = NULL;
return self;
}
void deleteHyperKaos(HyperKaos* self)
{
free(self);
}
void cleanHyperKaos(HyperKaos* self)
{
Kaos* here = self->head;
Kaos* next;
if (self->head == NULL) return;
else
{
next = here->next;
while (here != NULL)
{
here->destroy(here);
here = next;
if (here != NULL)
next = here->next;
}
}
self->head = NULL;
}
void addKaos(HyperKaos* self, Kaos* target)
{
Kaos* here = self->head;
Kaos* next;
if (self->head == NULL)
self->head = target;
else
{
next = here->next;
while (next != NULL)
{
here = next;
next = here->next;
}
here->next = target;
}
}
void run(HyperKaos* self)
{
Kaos* here = self->head;
Kaos* next;
savestate *= self->kaosID;
if (self->head == NULL) return;
else
{
next = here->next;
while (here != NULL)
{
here->run(here);
here = next;
if (here != NULL)
next = here->next;
}
}
}
int notCompleted(int x)
{
if (savestate%x) return 1;
else return 0;
}
int hasCompleted(int x)
{
if (!notCompleted(x)) return 1;
else return 0;
}