diff --git a/Engine.c b/Engine.c index b696c04..0229fa8 100644 --- a/Engine.c +++ b/Engine.c @@ -119,6 +119,16 @@ void interact() case B_BUTTON: spellbutton = 1; break; + case L_BUTTON: + bookMark--; + if (bookMark == -1) + bookMark = 1; + break; + case R_BUTTON: + bookMark++; + if (bookMark == 2) + bookMark = 0; + break; case PAUSE_BUTTON: pausemenu(); break; @@ -172,8 +182,8 @@ void kListen(int* whichKaos) { if (spellbutton) { - spellFlag = 0; - run(spellBook[0]); + spellFlag = bookMark; + run(spellBook[spellFlag]); synergize(); spellFlag = -1; } @@ -269,12 +279,23 @@ void writeSpellBook() spellBook = malloc(4*sizeof(HyperKaos**)); spellBook[0] = testSpell; + + testSpell = newHyperKaos(1,0,0,0,0,0); + Kaos* stopPlayer2 = newManip(hero, 0,0); + Kaos* flash = newSpell_Flash(); + addKaos(testSpell, stopPlayer2); + addKaos(testSpell, flash); + + spellBook[1] = testSpell; + } void burnSpellBook() { cleanHyperKaos(spellBook[0]); deleteHyperKaos(spellBook[0]); + cleanHyperKaos(spellBook[1]); + deleteHyperKaos(spellBook[1]); free(spellBook); } diff --git a/Kaos.c b/Kaos.c index 7ab3551..e18a0de 100644 --- a/Kaos.c +++ b/Kaos.c @@ -517,6 +517,53 @@ void deleteSpell_Beam(Kaos* target) { Spell_Beam* kSelf = target->kType; + SDL_FreeSurface(kSelf->aura); + free(kSelf); + free(target); +} + +Kaos* newSpell_Flash() +{ + Kaos* core = rawKaos(); + Spell_Beam* self = malloc(sizeof(Spell_Flash)); + + self->core = core; + core->kType = self; + + self->aura = loadImage("assets/img/fx/mactivate.png"); + SDL_SetAlpha(self->aura, SDL_SRCALPHA|SDL_RLEACCEL, 124); + core->run = &runSpell_Flash; + core->destroy = &deleteSpell_Flash; + + return core; +} + +void runSpell_Flash(Kaos* self) +{ + Spell_Flash* kSelf = self->kType; + int i; + SDL_Rect offset, clip; + offset.x = hero->point.x - 20; + offset.y = hero->point.y - 56; + clip.x = 0; + clip.y = 0; + clip.w = 41; + clip.h = 72; + for (i = 0; i < 8; i++) + { + clip.x = 41*i; + timeStart(fps); + renderBackground(); + renderForeground(); + applySurface(offset.x, offset.y, kSelf->aura, screen, &clip); + SDL_Flip(screen); + timeDilation(); + } +} + +void deleteSpell_Flash(Kaos* target) +{ + Spell_Flash* kSelf = target->kType; SDL_FreeSurface(kSelf->aura); free(kSelf); free(target); diff --git a/Kaos.h b/Kaos.h index d150ca9..a9c3d95 100644 --- a/Kaos.h +++ b/Kaos.h @@ -83,6 +83,12 @@ typedef struct kaos_Spell_Beam SDL_Surface* aura; } Spell_Beam; +typedef struct kaos_Spell_Flash +{ + Kaos* core; + SDL_Surface* aura; +} Spell_Flash; + Kaos* rawKaos(); Kaos* newConversation(int i); @@ -125,4 +131,8 @@ void deleteWait(Kaos* target); Kaos* newSpell_Beam(); void runSpell_Beam(Kaos* self); -void deleteSpell_Beam(Kaos* target); \ No newline at end of file +void deleteSpell_Beam(Kaos* target); + +Kaos* newSpell_Flash(); +void runSpell_Flash(Kaos* self); +void deleteSpell_Flash(Kaos* target); \ No newline at end of file diff --git a/assets/img/fx/gate.png b/assets/img/fx/gate.png new file mode 100644 index 0000000..e04a008 Binary files /dev/null and b/assets/img/fx/gate.png differ diff --git a/assets/img/fx/mactivate.png b/assets/img/fx/mactivate.png new file mode 100644 index 0000000..68ce84c Binary files /dev/null and b/assets/img/fx/mactivate.png differ diff --git a/assets/img/fx/timegate.png b/assets/img/fx/timegate.png new file mode 100644 index 0000000..9fbeef0 Binary files /dev/null and b/assets/img/fx/timegate.png differ diff --git a/extern.h b/extern.h index 17bbe94..91b2d8e 100644 --- a/extern.h +++ b/extern.h @@ -19,6 +19,7 @@ extern int spellFlag; extern long long int savestate; extern int spellKnowledge; +extern int bookMark; extern Room* menuBG; extern SDL_Surface* saveMenu; diff --git a/main.c b/main.c index 896f1a5..1cb3c24 100644 --- a/main.c +++ b/main.c @@ -51,6 +51,7 @@ Mix_Music* menuBGM = NULL; long long int savestate = 2; int spellKnowledge = 2; +int bookMark = 0; Room** mapData = NULL; Room** mapBuffer = NULL;