diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 67 | ||||
-rw-r--r-- | src/globals.c | 1 | ||||
-rw-r--r-- | src/globals.h | 1 | ||||
-rw-r--r-- | src/main.c | 10 | ||||
-rw-r--r-- | src/player.c | 28 |
5 files changed, 78 insertions, 29 deletions
@@ -401,23 +401,23 @@ static void step(int d) b->msg = 0; b->msglen = 0; if (!lenin_until_hadouken) { - b->txrrow = 7; - b->txrcol = 2 + rand() % 2; - b->rate = 75 + (rand() % 50 - 25); - b->yvel = rand() % 50 - 25; - b->yvel = b->yvel < 0 ? b->yvel - 125 : b->yvel + 125; - b->xvel = rand() % 50 - 25; - b->xvel = b->yvel < 0 ? b->yvel - 125 : b->yvel + 125; + b->txrrow = 7; + b->txrcol = 2 + rand() % 2; + b->rate = 75 + (rand() % 50 - 25); + b->yvel = rand() % 50 - 25; + b->yvel = b->yvel < 0 ? b->yvel - 125 : b->yvel + 125; + b->xvel = rand() % 50 - 25; + b->xvel = b->yvel < 0 ? b->yvel - 125 : b->yvel + 125; Mix_PlayChannel(-1, tthadouken, 0); lenin_until_hadouken = 3; } else { - b->txrrow = 8; - b->txrcol = rand() % 4; - 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; + b->txrrow = 8; + b->txrcol = rand() % 4; + 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--; } @@ -931,6 +931,26 @@ void changeroom(int out) SDL_FreeSurface(s); } } + + { + SDL_SetTextureAlphaMod(tttxr, 32); + SDL_SetRenderTarget(ttrdr, lighttxr); + SDL_RenderClear(ttrdr); + int i; + for (i = 0; i != r->bodies_count; ++i) { + tt_body *b = r->bodies + i; + if ((7 == b->txrrow && b->txrcol <= 7) || + b->txrrow == 11) { + SDL_Rect src = { 16 * 14, 16 * 12, 32, 32 }; + SDL_Rect d = { b->x + fullx + transx, + b->y + fully + transy, 64, 64 }; + SDL_RenderCopy(ttrdr, tttxr, &src, &d); + } + } + SDL_SetTextureAlphaMod(tttxr, 255); + SDL_SetRenderTarget(ttrdr, 0); + SDL_RenderCopy(ttrdr, lighttxr, 0, 0); + } } { int i, j; @@ -986,6 +1006,25 @@ void changeroom(int out) (ttplayer.rem / 100 % 2)), 16 * 6, 16, 16 }; SDL_RenderCopy(ttrdr, tttxr, &s, &d); + + { + SDL_SetTextureAlphaMod(tttxr, 32); + SDL_SetRenderTarget(ttrdr, lighttxr); + SDL_RenderClear(ttrdr); + int i; + for (i = 0; i != r->bodies_count; ++i) { + tt_body *b = r->bodies + i; + if ((7 == b->txrrow && b->txrcol <= 7) || + b->txrrow == 11) { + SDL_Rect src = { 16 * 14, 16 * 12, 32, 32 }; + SDL_Rect d = { b->x + transx, b->y + transy, 64, 64 }; + SDL_RenderCopy(ttrdr, tttxr, &src, &d); + } + } + SDL_SetTextureAlphaMod(tttxr, 255); + SDL_SetRenderTarget(ttrdr, 0); + SDL_RenderCopy(ttrdr, lighttxr, 0, 0); + } } { SDL_Rect d = { 0, 0, 14, 540 }; diff --git a/src/globals.c b/src/globals.c index 5d52d5d..d8ff085 100644 --- a/src/globals.c +++ b/src/globals.c @@ -5,6 +5,7 @@ SDL_Window *ttwdw; TTF_Font *ttfont; SDL_Texture *tttxr; +SDL_Texture *lighttxr; SDL_Renderer *ttrdr; diff --git a/src/globals.h b/src/globals.h index 2169957..199b262 100644 --- a/src/globals.h +++ b/src/globals.h @@ -12,6 +12,7 @@ extern SDL_Window *ttwdw; extern TTF_Font *ttfont; extern SDL_Texture *tttxr; +extern SDL_Texture *lighttxr; extern SDL_Renderer *ttrdr; @@ -23,10 +23,14 @@ 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"); + ttrdr = SDL_CreateRenderer( + ttwdw, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + tttxr = loadtxr("data/txr.bmp"); + lighttxr = SDL_CreateTexture(ttrdr, SDL_PIXELFORMAT_RGBA8888, + SDL_TEXTUREACCESS_TARGET, 950, 540); + SDL_SetTextureBlendMode(lighttxr, SDL_BLENDMODE_ADD); ttfont = TTF_OpenFont("data/font.otf", 24); grib = Mix_LoadMUS("data/grib.ogg"); ussr = Mix_LoadMUS("data/ussr.ogg"); diff --git a/src/player.c b/src/player.c index 2c7fe65..e9e06fe 100644 --- a/src/player.c +++ b/src/player.c @@ -3,7 +3,6 @@ #include "globals.h" #include <math.h> - void tt_player_draw() { int i, j; @@ -84,20 +83,25 @@ void tt_player_draw() ttplayer.y - 32 + r * sin(f), 64, 96 }; SDL_RenderCopy(ttrdr, tttxr, &s, &d); } -/* - { - SDL_BlendMode mode; - SDL_GetRenderDrawBlendMode(ttrdr, &mode); - SDL_SetRenderDrawBlendMode(ttrdr, SDL_BLENDMODE_ADD); - SDL_Texture *txr = SDL_CreateTexture(ttrdr, SDL_PIXELFORMAT_RGBA8888, - SDL_TEXTUREACCESS_TARGET, 950, 540); - SDL_SetRenderTarget(ttrdr, txr); + { + SDL_SetTextureAlphaMod(tttxr, 32); + SDL_SetRenderTarget(ttrdr, lighttxr); + SDL_RenderClear(ttrdr); + int i; + for (i = 0; i != r->bodies_count; ++i) { + tt_body *b = r->bodies + i; + if ((7 == b->txrrow && b->txrcol <= 7) || b->txrrow == 11) { + SDL_Rect src = { 16 * 14, 16 * 12, 32, 32 }; + SDL_Rect d = { b->x, b->y, 64, 64 }; + SDL_RenderCopy(ttrdr, tttxr, &src, &d); + } + } + SDL_SetTextureAlphaMod(tttxr, 255); SDL_SetRenderTarget(ttrdr, 0); - SDL_RenderCopy(ttrdr, txr, 0, 0); - SDL_SetRenderDrawBlendMode(ttrdr, mode); + SDL_RenderCopy(ttrdr, lighttxr, 0, 0); } -*/ + { SDL_Rect src = { 0, 16 * 11, 16, 16 }; SDL_Rect d = { 20 + TT_ROOM_W * 32 + 32, 12 + 32, 64, 64 }; |