all repos — hyperkaos @ main

lightweight modular puzzle/adventure game engine in C with SDL 1.2

HyperKaos.c (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#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->tombStone = 0;
  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;
}