hyperkaos/HyperKaos.c

90 lines
No EOL
1.4 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;
#include "extern.h"
HyperKaos* newHyperKaos(int id, int type, int x, int y, int w, int h)
{
HyperKaos* self = (HyperKaos*)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);
}
//
// chains of events
//
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;
}