diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2021-03-02 23:02:35 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2021-03-02 23:02:35 +0300 |
commit | 0effd8a331b66c3e7ee2411e0675584215367feb (patch) | |
tree | a048f36867bfdafc99b3742cc5cc6a870a7a98a5 | |
parent | 75c4749d444921135de90960244d493bd0ddeb64 (diff) | |
download | takethis-0effd8a331b66c3e7ee2411e0675584215367feb.tar takethis-0effd8a331b66c3e7ee2411e0675584215367feb.tar.xz takethis-0effd8a331b66c3e7ee2411e0675584215367feb.zip |
HADOUKEN!!!
-rw-r--r-- | data/hadouken.wav | bin | 0 -> 208974 bytes | |||
-rw-r--r-- | src/game.c | 40 | ||||
-rw-r--r-- | src/globals.c | 1 | ||||
-rw-r--r-- | src/globals.h | 1 | ||||
-rw-r--r-- | src/main.c | 26 |
5 files changed, 44 insertions, 24 deletions
diff --git a/data/hadouken.wav b/data/hadouken.wav Binary files differnew file mode 100644 index 0000000..17c4478 --- /dev/null +++ b/data/hadouken.wav @@ -5,9 +5,11 @@ #include <SDL2/SDL.h> #include <stdio.h> -int magic = 0; -int first_gulag = 1; -int fullscreen = 0; +int magic = 0; +static int first_gulag = 1; +static int fullscreen = 0; +static int lenin_grib = 0; +static int lenin_until_hadouken = 3; static int ticks; @@ -66,6 +68,8 @@ static void save() { FILE *f = fopen("save", "w"); outnum(f, first_gulag); + outnum(f, lenin_grib); + outnum(f, lenin_until_hadouken); if (curmus == grib) fputs("g\n", f); else if (curmus == ussr) fputs("u\n", f); @@ -162,8 +166,10 @@ static void load() { FILE *f = fopen("save", "r"); if (!f) return; - first_gulag = readnum(f); - int c = fgetc(f); + first_gulag = readnum(f); + lenin_grib = readnum(f); + lenin_until_hadouken = readnum(f); + int c = fgetc(f); if (c == 'g') { if (curmus != grib) { curmus = grib; @@ -376,7 +382,6 @@ static void step(int d) ttplayer.lenin_pos = oldpos; ttplayer.lenin_vel *= -1; } - static int lenin_grib = 0; if (ttplayer.lenin_rem % 1000 > 500) { if (!lenin_grib) { lenin_grib = 1; @@ -394,15 +399,26 @@ static void step(int d) b->txrrow = 8; b->txrcol = rand() % 4; b->anim = 4; - b->rate = 150 + (rand() % 50 - 25); b->collision_act = colact_instgulag; b->msg = 0; b->msglen = 0; - b->yvel = rand() % 100 - 50; - b->yvel = b->yvel < 0 ? b->yvel - 50 : b->yvel + 50; - b->xvel = rand() % 100 - 50; - b->xvel = b->yvel < 0 ? b->yvel - 50 : b->yvel + 50; - Mix_PlayChannel(-1, ttlenin, 0); + if (!lenin_until_hadouken) { + b->rate = 75 + (rand() % 50 - 25); + b->yvel = rand() % 100 - 50; + b->yvel = b->yvel < 0 ? b->yvel - 100 : b->yvel + 100; + b->xvel = rand() % 100 - 50; + b->xvel = b->yvel < 0 ? b->yvel - 100 : b->yvel + 100; + Mix_PlayChannel(-1, tthadouken, 0); + lenin_until_hadouken = 3; + } else { + b->rate = 150 + (rand() % 50 - 25); + b->yvel = rand() % 100 - 50; + b->yvel = b->yvel < 0 ? b->yvel - 50 : b->yvel + 50; + b->xvel = rand() % 100 - 50; + b->xvel = b->yvel < 0 ? b->yvel - 50 : b->yvel + 50; + Mix_PlayChannel(-1, ttlenin, 0); + lenin_until_hadouken--; + } } } else if (lenin_grib) lenin_grib = 0; diff --git a/src/globals.c b/src/globals.c index 800ece3..5d52d5d 100644 --- a/src/globals.c +++ b/src/globals.c @@ -8,6 +8,7 @@ SDL_Texture *tttxr; SDL_Renderer *ttrdr; +Mix_Chunk *tthadouken; Mix_Chunk *ttlenin; Mix_Chunk *ttcoin; Mix_Chunk *ttdoor; diff --git a/src/globals.h b/src/globals.h index a3189da..2169957 100644 --- a/src/globals.h +++ b/src/globals.h @@ -15,6 +15,7 @@ extern SDL_Texture *tttxr; extern SDL_Renderer *ttrdr; +extern Mix_Chunk *tthadouken; extern Mix_Chunk *ttlenin; extern Mix_Chunk *ttcoin; extern Mix_Chunk *ttdoor; @@ -23,19 +23,20 @@ int main(int argc, char **argv) Mix_Init(MIX_INIT_OGG); Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 4096); Mix_AllocateChannels(4); - ttwdw = SDL_CreateWindow("T A K E T H I S", SDL_WINDOWPOS_UNDEFINED, + ttwdw = SDL_CreateWindow("T A K E T H I S", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 950, 540, 0); - ttrdr = SDL_CreateRenderer(ttwdw, -1, SDL_RENDERER_ACCELERATED); - tttxr = loadtxr("data/txr.bmp"); - ttfont = TTF_OpenFont("data/font.otf", 24); - grib = Mix_LoadMUS("data/grib.ogg"); - ussr = Mix_LoadMUS("data/ussr.ogg"); - stalin = Mix_LoadMUS("data/stalin.ogg"); - lenin = Mix_LoadMUS("data/lenin.ogg"); - ttcoin = Mix_LoadWAV("data/coin.wav"); - ttdoor = Mix_LoadWAV("data/door.wav"); - ttlenin = Mix_LoadWAV("data/lenin.wav"); - curmus = 0; + ttrdr = SDL_CreateRenderer(ttwdw, -1, SDL_RENDERER_ACCELERATED); + tttxr = loadtxr("data/txr.bmp"); + ttfont = TTF_OpenFont("data/font.otf", 24); + grib = Mix_LoadMUS("data/grib.ogg"); + ussr = Mix_LoadMUS("data/ussr.ogg"); + stalin = Mix_LoadMUS("data/stalin.ogg"); + lenin = Mix_LoadMUS("data/lenin.ogg"); + ttcoin = Mix_LoadWAV("data/coin.wav"); + ttdoor = Mix_LoadWAV("data/door.wav"); + ttlenin = Mix_LoadWAV("data/lenin.wav"); + tthadouken = Mix_LoadWAV("data/hadouken.wav"); + curmus = 0; tt_map_load(); srand(time(0)); @@ -49,6 +50,7 @@ int main(int argc, char **argv) SDL_DestroyRenderer(ttrdr); SDL_DestroyWindow(ttwdw); Mix_HaltMusic(); + Mix_FreeChunk(tthadouken); Mix_FreeChunk(ttlenin); Mix_FreeChunk(ttcoin); Mix_FreeChunk(ttdoor); |