working on fleshing out the spellbook -- starting setup for phase-shift/time-travel spells

This commit is contained in:
Iris Lightshard 2018-12-14 14:52:24 -08:00
parent 1fed6282f5
commit 9c9f87fa14
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
8 changed files with 83 additions and 3 deletions

View file

@ -119,6 +119,16 @@ void interact()
case B_BUTTON: case B_BUTTON:
spellbutton = 1; spellbutton = 1;
break; break;
case L_BUTTON:
bookMark--;
if (bookMark == -1)
bookMark = 1;
break;
case R_BUTTON:
bookMark++;
if (bookMark == 2)
bookMark = 0;
break;
case PAUSE_BUTTON: case PAUSE_BUTTON:
pausemenu(); pausemenu();
break; break;
@ -172,8 +182,8 @@ void kListen(int* whichKaos)
{ {
if (spellbutton) if (spellbutton)
{ {
spellFlag = 0; spellFlag = bookMark;
run(spellBook[0]); run(spellBook[spellFlag]);
synergize(); synergize();
spellFlag = -1; spellFlag = -1;
} }
@ -269,12 +279,23 @@ void writeSpellBook()
spellBook = malloc(4*sizeof(HyperKaos**)); spellBook = malloc(4*sizeof(HyperKaos**));
spellBook[0] = testSpell; 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() void burnSpellBook()
{ {
cleanHyperKaos(spellBook[0]); cleanHyperKaos(spellBook[0]);
deleteHyperKaos(spellBook[0]); deleteHyperKaos(spellBook[0]);
cleanHyperKaos(spellBook[1]);
deleteHyperKaos(spellBook[1]);
free(spellBook); free(spellBook);
} }

47
Kaos.c
View file

@ -521,3 +521,50 @@ void deleteSpell_Beam(Kaos* target)
free(kSelf); free(kSelf);
free(target); 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);
}

10
Kaos.h
View file

@ -83,6 +83,12 @@ typedef struct kaos_Spell_Beam
SDL_Surface* aura; SDL_Surface* aura;
} Spell_Beam; } Spell_Beam;
typedef struct kaos_Spell_Flash
{
Kaos* core;
SDL_Surface* aura;
} Spell_Flash;
Kaos* rawKaos(); Kaos* rawKaos();
Kaos* newConversation(int i); Kaos* newConversation(int i);
@ -126,3 +132,7 @@ void deleteWait(Kaos* target);
Kaos* newSpell_Beam(); Kaos* newSpell_Beam();
void runSpell_Beam(Kaos* self); void runSpell_Beam(Kaos* self);
void deleteSpell_Beam(Kaos* target); void deleteSpell_Beam(Kaos* target);
Kaos* newSpell_Flash();
void runSpell_Flash(Kaos* self);
void deleteSpell_Flash(Kaos* target);

BIN
assets/img/fx/gate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
assets/img/fx/mactivate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/img/fx/timegate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View file

@ -19,6 +19,7 @@ extern int spellFlag;
extern long long int savestate; extern long long int savestate;
extern int spellKnowledge; extern int spellKnowledge;
extern int bookMark;
extern Room* menuBG; extern Room* menuBG;
extern SDL_Surface* saveMenu; extern SDL_Surface* saveMenu;

1
main.c
View file

@ -51,6 +51,7 @@ Mix_Music* menuBGM = NULL;
long long int savestate = 2; long long int savestate = 2;
int spellKnowledge = 2; int spellKnowledge = 2;
int bookMark = 0;
Room** mapData = NULL; Room** mapData = NULL;
Room** mapBuffer = NULL; Room** mapBuffer = NULL;