derp, forgot to add all the actual lighning beam stuff
PGP Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAlvrPUUACgkQO3+8IhRO Y5hexRAAl9FRmr0fJ77ykOhhn3l9z+sMyr621mLS1FpjdFyD7Hx9pGWIedkb+T9m EB6ykQBQxZdBUjiiuLDoEPfwlxdD0EYYGCMjEeVI4u3tDUZWQkeOffckJ6S8g3/V Vb6wLA4N6bmYP2uV/59DK8hodt3IIFRZq+TmgF0nFeZr9fx00lBpBoCwwHSJLF1p ynz/RUu79am4CHw92kri+i4llocGb3rfJbLUmTQOGavZIl9/eVCLJy0GQxeSURA1 4NkyFLrJvNXK2o7UoYYnJdVrAMHqGnmTmrPigPJp3tGGq1vm6+kBsYqmflmJ2fYa K3TVXVDO30xVNNZdowEa36jc/SK7bpQBgtwrSFyCKIZykHRfCcqsFA7aJW7uyHYi 2j54RlBcybuyFZvDTLXWgRiQXHrYrvvoRBkzqVg0rPPnC59fxF0vK1h/UFMsQoz4 5Pf+cpf2ZtkyBEd+7B45WpzsgRyy9rn3p8wsaKesGjkocc/qclTdJ/TTLKSpCPX0 i/M8wYSH1CxbmCnXQVosLmssUNFGjqsZ0da5ou5wC+UpUmrVbX8Gthsm8pV6o6st wqkFcUFSzSKYsPDf5ZKlYIy1A1GF5wcWwoBYwQaBjZiIn5PB5+LPiY0DKAWppsAN L1yeNObvSyUSN7fY9AqSUCEzqKirXIRJRuiZl5SHVn1rI/TFsk4= =t/hR -----END PGP SIGNATURE-----
@@ -18,6 +18,7 @@ #include "TextBox.h"
#include "Kaos.h" #include "HyperKaos.h" #include "Scene.h" +#include "Synergy.h" #include "extern.h"@@ -109,6 +110,7 @@ actionbutton = 1;
break; case B_BUTTON: spellbutton = 1; + break; case PAUSE_BUTTON: pausemenu(); break;@@ -156,11 +158,17 @@ break;
case SDL_QUIT: quit = 1; playing = 0; break; } } - walkAnim(hero); } void kListen(int* whichKaos) { + if (spellbutton) + { + spellFlag = 0; + run(spellBook[0]); + synergize(); + spellFlag = -1; + } if (*whichKaos >= 0) { run(rightHere->eventTriggers[*whichKaos]);@@ -222,10 +230,32 @@ bgmData = malloc(8*sizeof(Mix_Music*));
sfxData = malloc(24*sizeof(Mix_Chunk*)); kaosData = malloc(124*sizeof(Kaos*)); theatre = malloc(8*sizeof(Scene*)); + + writeSpellBook(); + printf("Init complete\n"); return 1; } +void writeSpellBook() +{ + HyperKaos* testSpell = newHyperKaos(1,0,0,0,0,0); + Kaos* stopPlayer = newManip(hero, 0,0); + Kaos* beam = newSpell_Beam(); + addKaos(testSpell, stopPlayer); + addKaos(testSpell, beam); + + spellBook = malloc(4*sizeof(HyperKaos**)); + spellBook[0] = testSpell; +} + +void burnSpellBook() +{ + cleanHyperKaos(spellBook[0]); + deleteHyperKaos(spellBook[0]); + free(spellBook); +} + void toggleFullscreen() { if (!fullscreen)@@ -254,7 +284,6 @@ void cleanup()
{ if(fullscreen) SDL_ShowCursor(1); - printf("Freeing map data\n"); unloadData(thisChunk);@@ -271,6 +300,8 @@ free(bgmData);
free(sfxData); free(theatre); + + burnSpellBook(); SDL_FreeSurface(textBoxBG); SDL_FreeSurface(nextArrow);
@@ -35,9 +35,25 @@ {
free(self); } -// -// chains of events -// +void cleanHyperKaos(HyperKaos* self) +{ + Kaos* here = self->head; + Kaos* next; + savestate *= self->kaosID; + if (self->head == NULL) return; + + else + { + next = here->next; + while (here != NULL) + { + here->destroy(here); + here = next; + if (here != NULL) + next = here->next; + } + } +} void addKaos(HyperKaos* self, Kaos* target) {
@@ -10,6 +10,7 @@ } HyperKaos;
HyperKaos* newHyperKaos(int id, int type, int x, int y, int w, int h); void deleteHyperKaos(HyperKaos* target); +void cleanHyperKaos(HyperKaos* self); void run(HyperKaos* self); void addKaos(HyperKaos* self, Kaos* target);
@@ -358,7 +358,7 @@ switch (kSelf->type)
{ case 'w': deleteWarp(rightHere, kSelf->index); - break; + break; case 't': deleteTrigger(rightHere, kSelf->index); break;@@ -367,6 +367,9 @@ deleteObstacle(rightHere, kSelf->index);
break; case 'f': deleteFgObj(rightHere, kSelf->index); + break; + case 's': + deleteSigil(rightHere, kSelf->index); break; default:break; }@@ -416,5 +419,103 @@
void deleteWait(Kaos* target) { free(target->kType); + free(target); +} + +Kaos* newSpell_Beam() +{ + Kaos* core = rawKaos(); + Spell_Beam* self = malloc(sizeof(Spell_Beam)); + + self->core = core; + core->kType = self; + + self->aura = loadImage("assets/img/fx/spellBeam.png"); + SDL_SetAlpha(self->aura, SDL_SRCALPHA|SDL_RLEACCEL, 124); + core->run = &runSpell_Beam; + core->destroy = &deleteSpell_Beam; + + return core; +} + +void runSpell_Beam(Kaos* self) +{ + int i; + char facing; + SDL_Rect offset, clip; + Spell_Beam* kSelf = self->kType; + if (playerFaces(hero, 's')) + { + facing = 's'; + offset.x = hero->boundBox.x - hero->boundBox.w/2; + offset.y = hero->boundBox.y + hero->boundBox.h; + clip.x = 0; + clip.y = 128; + clip.w = 32; + clip.h = 180; + } + else if (playerFaces(hero, 'w')) + { + facing = 'w'; + offset.x = hero->boundBox.x - SCREEN_WIDTH; + offset.y = hero->boundBox.y - hero->boundBox.h/2; + clip.x = 15; + clip.y = 0; + clip.w = 320; + clip.h = 32; + } + else if (playerFaces(hero, 'e')) + { + facing = 'e'; + offset.x = hero->boundBox.x + hero->boundBox.w; + offset.y = hero->boundBox.y - hero->boundBox.h/2; + clip.x = 0; + clip.y = 0; + clip.w = 320; + clip.h = 32; + } + else + { + facing = 'n'; + offset.x = hero->boundBox.x - hero->boundBox.w/2; + offset.y = hero->boundBox.y - SCREEN_HEIGHT; + clip.x = 128; + clip.y = 128; + clip.w = 32; + clip.h = 180; + } + + for (i = 0; i < 16; i++) + { + timeStart(fps); + renderBackground(); + renderForeground(); + switch (facing) + { + case 'n': + clip.x = 128 + (i%4)*32; + applySurface(offset.x, offset.y, kSelf->aura, screen, &clip); + break; + case 's': + clip.x = (i%4)*32; + applySurface(offset.x, offset.y, kSelf->aura, screen, &clip); + break; + case 'w': + case 'e': + clip.y = (i%4)*32; + applySurface(offset.x, offset.y, kSelf->aura, screen, &clip); + break; + } + SDL_Flip(screen); + timeDilation(); + } +} + +void deleteSpell_Beam(Kaos* target) +{ + Spell_Beam* kSelf = target->kType; + + SDL_FreeSurface(kSelf->aura); + free(kSelf); free(target); }
@@ -75,6 +75,12 @@ char type;
int frames; } Wait; +typedef struct kaos_Spell_Beam +{ + Kaos* core; + SDL_Surface* aura; +} Spell_Beam; + Kaos* rawKaos(); Kaos* newConversation(int i);@@ -112,3 +118,7 @@
Kaos* newWait(char t, int i); void runWait(Kaos* self); void deleteWait(Kaos* target); + +Kaos* newSpell_Beam(); +void runSpell_Beam(Kaos* self); +void deleteSpell_Beam(Kaos* target);
@@ -304,7 +304,7 @@ for (j = 0; j < i; j++)
temp[j] = self->fgObject[j]; for (j = i + 1; j < self->numberOfObj; j++) temp[j-1] = self->fgObject[j]; - free(self->fgObject[i].spriteSheet); + SDL_FreeSurface(self->fgObject[i].spriteSheet); free(self->fgObject); self->fgObject = temp; temp = NULL;
@@ -19,13 +19,13 @@ typedef struct timer Timer;
typedef struct textBox TextBox; #include "extern.h" -Synergy* newSynergy(int s, char d, SDL_Rect z, HyperKaos* t) +Synergy* newSynergy(int s, char d, int x, int y, int w, int h, HyperKaos* t) { Synergy* self = malloc(sizeof(Synergy)); self->spell = s; self->dir = d; - self->zone = z; + self->zone = (SDL_Rect){x, y, w, h}; self->trigger = t; return self;@@ -36,16 +36,16 @@ {
free(target); } -void Synergize() +void synergize() { int i; - Synergy* sigil = rightHere->sigils[0]; + Synergy* sigil; for (i = 0; i < rightHere->numberOfSigils; i++) { + sigil = rightHere->sigils[i]; if (sigil->spell == spellFlag && playerFaces(hero, sigil->dir) && playerIsInRect(hero, &(sigil->zone))) run(sigil->trigger); - sigil++; } }
@@ -6,7 +6,7 @@ SDL_Rect zone;
HyperKaos* trigger; } Synergy; -Synergy* newSynergy(int s, char d, SDL_Rect z, HyperKaos* t); +Synergy* newSynergy(int s, char d, int x, int y, int w, int h, HyperKaos* t); void deleteSynergy(Synergy* target); -void Synergize();+void synergize();
@@ -4,7 +4,9 @@ #include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h" #include "SDL/SDL_mixer.h" +#include "config.h" #include "enum.h" + #include "Engine.h" #include "Player.h" #include "Room.h"@@ -12,6 +14,7 @@ #include "Kaos.h"
#include "HyperKaos.h" #include "TextBox.h" #include "Scene.h" +#include "Synergy.h" typedef struct timer Timer; #include "extern.h"@@ -78,6 +81,9 @@ kaosData[4] = newManip(hero, 0 ,0);
kaosData[5] = newConversation(2); kaosData[6] = newConversation(3); kaosData[7] = newConversation(4); + kaosData[12] = newErase('f', 1); + kaosData[13] = newErase('o', 1); + kaosData[14] = newErase('s', 0); HyperKaos* choiceBranchA = newHyperKaos(1,0, 0, 0, 0, 0); addKaos(choiceBranchA, kaosData[7]);@@ -91,14 +97,26 @@ addKaos(choiceBranchB, kaosData[2]);
addTrigger(mapBuffer[3], choiceBranchB); choiceBranchB = NULL; + HyperKaos* destroyChp2 = newHyperKaos(1,0,0,0,0,0); + + addKaos(destroyChp2, kaosData[12]); + addKaos(destroyChp2, kaosData[13]); + addKaos(destroyChp2, kaosData[14]); + + Synergy* testSigil = newSynergy(0,'e', 0, 74, 256, 48, destroyChp2); + addSigil(mapBuffer[0], testSigil); + + destroyChp2 = NULL; + testSigil = NULL; + kaosData[8] = newChoice("Let her know?", "Sure thing", "Nope", mapBuffer[3]->eventTriggers[0], mapBuffer[3]->eventTriggers[1]); if(notCompleted(3)) { HyperKaos* testTextBox = newHyperKaos(3, 0, 0, 0, 320, 180); + addKaos(testTextBox, kaosData[4]); addKaos(testTextBox, kaosData[0]); addKaos(testTextBox, kaosData[1]); - addKaos(testTextBox, kaosData[4]); addKaos(testTextBox, kaosData[8]); addTrigger(mapBuffer[3], testTextBox);@@ -135,15 +153,7 @@ addKaos(randomDudeConvo, kaosData[2]);
addTrigger(mapBuffer[1], randomDudeConvo); randomDudeConvo = NULL; - HyperKaos* chipDesc1 = newHyperKaos(1,1, 64, 64, 22, 55); - addKaos(chipDesc1, kaosData[5]); - addKaos(chipDesc1, kaosData[2]); - addTrigger(mapBuffer[0], chipDesc1); - chipDesc1 = NULL; - HyperKaos* chipDesc2 = newHyperKaos(1,1, 320 - 64 - 22, 64, 22, 55); - addKaos(chipDesc2, kaosData[5]); - addTrigger(mapBuffer[0], chipDesc2); - chipDesc2 = NULL; + break; case LEVEL2:@@ -186,7 +196,7 @@ printf("Unloading old map chunk\n");
switch(chunk) { case LEVEL1: - dataPurge(4,5,12,1,0); + dataPurge(4,5,15,1,0); break; case LEVEL2: dataPurge(2,0,0,0,0);@@ -204,7 +214,7 @@ mapData = mapBuffer;
mapBuffer = (Room**)malloc(64*sizeof(Room*)); if (hasMusic) Mix_PlayMusic(bgmData[0], -1); - printf("Mapbuffer clean\n"); + printf("Map buffer clean\n"); } void pager()