X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fanim.c;h=6d761f43b296ce0783c5889aa24472d1844d81e6;hb=2276a40b6ceb93c0e54317a6f3aa85c09e535f68;hp=7ecdf8fdc04d9aeadd06f7bbb6c0ef639016623b;hpb=b4daa7d0a171abb2a25609e89c323863e6246b0b;p=rocksndiamonds.git diff --git a/src/anim.c b/src/anim.c index 7ecdf8fd..6d761f43 100644 --- a/src/anim.c +++ b/src/anim.c @@ -137,6 +137,9 @@ struct GlobalAnimPartControlInfo int anim_delay_counter; int post_delay_counter; + int fade_delay_counter; + int fade_alpha; + boolean init_event_state; boolean anim_event_state; @@ -735,6 +738,7 @@ static void BlitGlobalAnimation(struct GlobalAnimPartControlInfo *part, Bitmap *fade_bitmap = (drawing_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source : drawing_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL); + int alpha = (c->fade_mode & FADE_MODE_FADE ? part->fade_alpha : g->alpha); int x, y; for (y = 0; y < c->stacked_yfactor; y++) @@ -781,6 +785,8 @@ static void BlitGlobalAnimation(struct GlobalAnimPartControlInfo *part, dst_x += part->viewport_x; dst_y += part->viewport_y; + SetBitmapAlphaNextBlit(src_bitmap, alpha); + if (drawing_target == DRAW_TO_SCREEN) blit_screen(src_bitmap, src_x, src_y, width, height, dst_x, dst_y); @@ -1535,6 +1541,7 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, struct GraphicInfo *g = &part->graphic_info; struct GraphicInfo *c = &part->control_info; boolean viewport_changed = SetGlobalAnimPart_Viewport(part); + int alpha = (g->alpha != -1 ? g->alpha : SDL_ALPHA_OPAQUE); // if game is paused, also pause playfield and door animations if (isPausedOnPlayfieldOrDoor(part)) @@ -1571,6 +1578,18 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, if (part->anim_random_frame == -1) part->anim_random_frame = GetSimpleRandom(g->anim_frames); + if (c->fade_mode & FADE_MODE_FADE) + { + // when fading in screen, first frame is 100 % transparent or opaque + part->fade_delay_counter = c->fade_delay + 1; + part->fade_alpha = (c->fade_mode == FADE_MODE_FADE_IN ? 0 : alpha); + } + else + { + part->fade_delay_counter = 0; + part->fade_alpha = -1; + } + if (c->direction & MV_HORIZONTAL) { int pos_bottom = part->viewport_height - g->height; @@ -1784,6 +1803,14 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, return ANIM_STATE_WAITING; } + if (part->fade_delay_counter > 0) + { + part->fade_delay_counter--; + part->fade_alpha = alpha * (c->fade_mode == FADE_MODE_FADE_IN ? + c->fade_delay - part->fade_delay_counter : + part->fade_delay_counter) / c->fade_delay; + } + // special case to prevent expiring loop sounds when playing PlayGlobalAnimSoundIfLoop(part); @@ -1934,9 +1961,13 @@ static void HandleGlobalAnim_Main(struct GlobalAnimMainControlInfo *anim, for (i = 0; i < num_parts; i++) anim->part[i].state = ANIM_STATE_INACTIVE; - // ... then set current animation parts to "running" + // ... then set current animation part to "running" ... part->state = ANIM_STATE_RUNNING; + // ... unless it is waiting for an initial event + if (part->init_event_state) + part->state = ANIM_STATE_WAITING; + anim->state = HandleGlobalAnim_Part(part, anim->state); if (anim->state & ANIM_STATE_RESTART)