all repos — hyperkaos @ main

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

main.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
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include "SDL/SDL_mixer.h"
#include <stdio.h>
#include "enum.h"
#include "Engine.h"
#include "Timer.h"
#include "Player.h"
#include "Room.h"
#include "TextBox.h"
#include "Kaos.h"
#include "HyperKaos.h"
#include "WorldData.h"
#include "Scene.h"

int fullscreen = 0;
int playing = 0;
int quit = 0;
int actionbutton = 0;
int spellbutton = 0;
int captive = 0;
int hasMusic = 0;

Timer fps = { 0 };
SDL_Event event;

SDL_Surface* screen = NULL;
SDL_Surface* window = NULL;
Room* rightHere = NULL;
HyperKaos** spellBook = NULL;

SDL_Surface* saveMenu = NULL;
SDL_Surface* textBoxBG = NULL;
SDL_Surface* choiceBox = NULL;
SDL_Surface* nextArrow = NULL;
SDL_Surface* selectArrow = NULL;
SDL_Surface* loadingTxt = NULL;
SDL_Surface* spellGlyphs = NULL;

TTF_Font* font = NULL;
SDL_Color textColor = {255, 255, 255};

Player* hero = NULL;
Room* menuBG = NULL;
Mix_Music* menuBGM = NULL;

long long int savestate = 2;
int spellKnowledge[10] = {1,1,0,0,0,0,0,0,0,0};
int bookMark = 0;

Room** mapData = NULL;
Room** mapBuffer = NULL;
TextBox** dialogueData = NULL;
Mix_Music** bgmData = NULL;
Mix_Chunk** sfxData = NULL;
Kaos** kaosData = NULL;
Scene** theatre = NULL;

int kaosFlag = -1;
int spellFlag = -1;

enum dataChunks thisChunk;
enum dataChunks nextChunk;

int main (int argc, char* args[])
{
  if (!init(argc, args))
  {
    printf("Init failed\n");
    return 1;
  }

  intro();

  while (!quit)
  {
    mainmenu();

    while (playing)
    {
      timeStart(&fps);
      interact();
      movePlayer(hero, rightHere);
      renderBackground();
      renderForeground();
      renderHUD();
      frameAdvance();
      kListen();
      pager();
    }
  }

  cleanup();
  return 0;
}