all repos — hyperkaos @ 9c9f87fa14fa72e9398b87048829092fa475cb45

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

working on fleshing out the spellbook -- starting setup for phase-shift/time-travel spells
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAlwUNCgACgkQO3+8IhRO
Y5jCgQ//bln/FzvhrSAAwXG5hDiRCHju9WwV+LWrLQMs6umbiCsFyFyiFfUL6XqM
nEHNBaWjZceUkI2UiR7MAOXlZ4u5I9xOVJIn/F4+2K1nlukUwYusjppeuKKVyeo3
NyQoQTFaBoc1dN6xiZnwUcVivlVttJuC/N4skA/riNUISEsulv+C7b7e9NJG0lnh
w21/rTbr87o5VhgaYsU/jOrRr5ODLY9bvlmlWmNdNsYcZNftbH5DhKY07mnRFqe3
eB6U2zEI2sup24NKsIqguKRVq1LpxPUCg5TIN73RnZGunrfcx7H3Usp7b738KF5n
Y1HQ5i23AHsbU5LG7Wrw5ci+zwLMhLyjf11Lcl03jV38XpMEkyEJwkr1QhUDgwyp
MBQ0RRnURhy4on03wov72HgINCFkDcNJA7kEg0P1fiNaEYKILQh0YGxx7M8MKlsG
vDVjLKsMuJn5fmqE1Nr1MFtos0LmYKvVjXwLmSzuDPdXQPnVKSi1ujB2z9z3Coqz
yRdTEapXl7dTIdLly9+HHQ2Lgpre2drRdwzZb2AlOM9FJSYKCfWCgayTaqr1BcUm
DN6a1FI/vyGW8oekkIiUae0t+h68fEOC1jiAyiP1B2aITAocJVKZ7O5zrdrTiHwY
Vw5QtQSzb/bPGdyoG0EORZMhswResf6iu4QevuKW6mz/vTKpBgA=
=4la3
-----END PGP SIGNATURE-----
commit

9c9f87fa14fa72e9398b87048829092fa475cb45

parent

1fed6282f56e78c5e5b77a2834b9555298c6b0c0

M Engine.cEngine.c

@@ -119,6 +119,16 @@ break;

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 @@ addKaos(testSpell, beam);

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); }
M Kaos.cKaos.c

@@ -520,4 +520,51 @@

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); }
M Kaos.hKaos.h

@@ -83,6 +83,12 @@ Kaos* core;

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);+void deleteSpell_Beam(Kaos* target); + +Kaos* newSpell_Flash(); +void runSpell_Flash(Kaos* self); +void deleteSpell_Flash(Kaos* target);
M extern.hextern.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;
M main.cmain.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;