DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[Tutorial] Animating menu cursor & End Level BJ w/ 3+ fr
Page 1 of 1
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:30 ago.

Topics: 163
Posts: 8152
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Tue Apr 05, 2011 8:07 pm
   Subject: [Tutorial] Animating menu cursor & End Level BJ w/ 3+ fr
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

This tutorial enhances the animation of the menu cursor and the BJ pics in the LevelCompleted screen, so now it can use as many frames as you like.

First off, go into VERSION.H, and add in these lines somewhere:

::: CODE :::
#define VGAGRANIM               // Enable new animation code for the menu cursor

#define FRAMES4MENU          8  // # of animation frames for menu pointer
#define ANIMSPEED4MENU       6  // Animation speed for menu pointer

#define FRAMES4LVLEND        8  // # of animation frames for Level Complete pics
#define ANIMSPEED4LVLEND     16 // Animation speed for Level Complete pics


FRAMES4MENU tells the code how many frames of animation to use for the menu cursor. ANIMSPEED4MENU sets the speed for the animation (One is the fastest).

FRAMES4LVLEND sets the number of frames to use for BJ's animation in the Level Complete screen. ANIMSPEED4LVLEND sets the speed of the animation.

Now, you'll need to go into GFXV_WL6.H (or GFXV_APO.H) to add in the new frames for the VGAGRAPH. Below this code ...

::: CODE :::
    C_CURSOR1PIC,                // 23
    C_CURSOR2PIC,                // 24

... insert this:
::: CODE :::
#if defined(VGAGRANIM)
    C_CURSOR3PIC,                //
    C_CURSOR4PIC,                //
    C_CURSOR5PIC,                //
    C_CURSOR6PIC,                //
    C_CURSOR7PIC,                //
    C_CURSOR8PIC,                //
#endif

And below this:
::: CODE :::
    // Lump Start
    L_GUYPIC,                    // 55

Insert this:
::: CODE :::
#if defined(VGAGRANIM)
    L_GUY2PIC,                    // 55
    L_GUY3PIC,                    // 55
    L_GUY4PIC,                    // 55
    L_GUY5PIC,                    // 55
    L_GUY6PIC,                    // 55
    L_GUY7PIC,                    // 55
    L_GUY8PIC,                    // 55
#endif

Search for "GUY2PIC", just below this code. You should see this:
::: CODE :::
    L_GUY2PIC,                   // 96

Change it to:
::: CODE :::
#if !defined(VGAGRANIM)
    L_GUY2PIC,                   // 96
#endif

When you add the animation frames in the VGAGRAPH using WDC or ChaosEdit, you'll need to delete the second BJ pic between the apostrophe and the BJ Wins pic. All BJ animation frames should be put where the first BJ pic is for the Level Complete screen.

Now, in WL_INTER.CPP, search for "Breathe Mr". You should see this:
::: CODE :::
//
// Breathe Mr. BJ!!!
//
void
BJ_Breathe (void)
{

Change the whole routine to read like this:
::: CODE :::
//
// Breathe Mr. BJ!!!
//
void
BJ_Breathe (void)
{
#ifndef VGAGRANIM
    static int which = 0, max = 10;
    int pics[2] = { L_GUYPIC, L_GUY2PIC };
#else
    static int which = 0, max = 0;
#endif

    SDL_Delay(5);

    if ((int32_t) GetTimeCount () - lastBreathTime > max)
    {
#ifdef VGAGRANIM
        which ++;
        if (which >= FRAMES4LVLEND) which = 0;
        VWB_DrawPic (0, 16, L_GUYPIC+which);
        max = ANIMSPEED4LVLEND;
#else
        which ^= 1;
        VWB_DrawPic (0, 16, pics[which]);
        max = 35;
#endif
        VW_UpdateScreen ();
        lastBreathTime = GetTimeCount();
    }
}

This is all the code you need to get the animation running, *but* the animation will "freeze" for a moment whenever a 100% or 0% is displayed in the ratios. This is because it uses the "VW_WaitVBL" command. So, let's fix that.

Do a search for "VBLWAIT". You should see this line:
::: CODE :::
#define VBLWAIT 30

Insert this line just below it:
::: CODE :::
#define BREATHCOUNT     (VBLWAIT/2)

Now, for every set of code in the LevelCompleted routine that has this:
::: CODE :::
            VW_WaitVBL (VBLWAIT);
            SD_StopSound ();

Change it to this:
::: CODE :::
#ifdef VGAGRANIM
        for (i = 0; i <= BREATHCOUNT; i++)
        {
            VW_WaitVBL (2);
            BJ_Breathe ();
            }                 
#else
            VW_WaitVBL (VBLWAIT);
#endif
            SD_StopSound ();


Go back to the beginning of the WL_MENU.CPP file now, and do a search for "CURSOR2". You should see this code:
::: CODE :::
                CA_CacheGrChunk (C_CURSOR1PIC);
                CA_CacheGrChunk (C_CURSOR2PIC);

Just below that, insert this:
::: CODE :::
#ifdef VGAGRANIM
                CA_CacheGrChunk (C_CURSOR3PIC);
                CA_CacheGrChunk (C_CURSOR4PIC);
                CA_CacheGrChunk (C_CURSOR5PIC);
                CA_CacheGrChunk (C_CURSOR6PIC);
                CA_CacheGrChunk (C_CURSOR7PIC);
                CA_CacheGrChunk (C_CURSOR8PIC);
                CA_CacheGrChunk (C_CURSOR9PIC);
                CA_CacheGrChunk (C_CURSOR10PIC);
                CA_CacheGrChunk (C_CURSOR11PIC);
                CA_CacheGrChunk (C_CURSOR12PIC);
                CA_CacheGrChunk (C_CURSOR13PIC);
                CA_CacheGrChunk (C_CURSOR14PIC);
                CA_CacheGrChunk (C_CURSOR15PIC);
                CA_CacheGrChunk (C_CURSOR16PIC);
#endif

Now, do a search for "CURSOR2" again. You should see this:
::: CODE :::
                UNCACHEGRCHUNK (C_CURSOR1PIC);
                UNCACHEGRCHUNK (C_CURSOR2PIC);

Just below that, insert this:
::: CODE :::
#ifdef VGAGRANIM
                UNCACHEGRCHUNK (C_CURSOR3PIC);
                UNCACHEGRCHUNK (C_CURSOR4PIC);
                UNCACHEGRCHUNK (C_CURSOR5PIC);
                UNCACHEGRCHUNK (C_CURSOR6PIC);
                UNCACHEGRCHUNK (C_CURSOR7PIC);
                UNCACHEGRCHUNK (C_CURSOR8PIC);
                UNCACHEGRCHUNK (C_CURSOR9PIC);
                UNCACHEGRCHUNK (C_CURSOR10PIC);
                UNCACHEGRCHUNK (C_CURSOR11PIC);
                UNCACHEGRCHUNK (C_CURSOR12PIC);
                UNCACHEGRCHUNK (C_CURSOR13PIC);
                UNCACHEGRCHUNK (C_CURSOR14PIC);
                UNCACHEGRCHUNK (C_CURSOR15PIC);
                UNCACHEGRCHUNK (C_CURSOR16PIC);
#endif

Yet again, do a search for "CURSOR2". Deja vu, you ought to see this code:
::: CODE :::
                CA_CacheGrChunk (C_CURSOR1PIC);
                CA_CacheGrChunk (C_CURSOR2PIC);

Again, insert this:
::: CODE :::
#ifdef VGAGRANIM
                CA_CacheGrChunk (C_CURSOR3PIC);
                CA_CacheGrChunk (C_CURSOR4PIC);
                CA_CacheGrChunk (C_CURSOR5PIC);
                CA_CacheGrChunk (C_CURSOR6PIC);
                CA_CacheGrChunk (C_CURSOR7PIC);
                CA_CacheGrChunk (C_CURSOR8PIC);
                CA_CacheGrChunk (C_CURSOR9PIC);
                CA_CacheGrChunk (C_CURSOR10PIC);
                CA_CacheGrChunk (C_CURSOR11PIC);
                CA_CacheGrChunk (C_CURSOR12PIC);
                CA_CacheGrChunk (C_CURSOR13PIC);
                CA_CacheGrChunk (C_CURSOR14PIC);
                CA_CacheGrChunk (C_CURSOR15PIC);
                CA_CacheGrChunk (C_CURSOR16PIC);
#endif

Do a search for "CURSOR2" another time. You should see this:
::: CODE :::
                UNCACHEGRCHUNK (C_CURSOR1PIC);
                UNCACHEGRCHUNK (C_CURSOR2PIC);

Insert this just below it:
::: CODE :::
#ifdef VGAGRANIM
                UNCACHEGRCHUNK (C_CURSOR3PIC);
                UNCACHEGRCHUNK (C_CURSOR4PIC);
                UNCACHEGRCHUNK (C_CURSOR5PIC);
                UNCACHEGRCHUNK (C_CURSOR6PIC);
                UNCACHEGRCHUNK (C_CURSOR7PIC);
                UNCACHEGRCHUNK (C_CURSOR8PIC);
                UNCACHEGRCHUNK (C_CURSOR9PIC);
                UNCACHEGRCHUNK (C_CURSOR10PIC);
                UNCACHEGRCHUNK (C_CURSOR11PIC);
                UNCACHEGRCHUNK (C_CURSOR12PIC);
                UNCACHEGRCHUNK (C_CURSOR13PIC);
                UNCACHEGRCHUNK (C_CURSOR14PIC);
                UNCACHEGRCHUNK (C_CURSOR15PIC);
                UNCACHEGRCHUNK (C_CURSOR16PIC);
#endif

Do a search for "CURSOR2" one last time. You should see this code:
::: CODE :::

            if (shape == C_CURSOR1PIC)
            {
                shape = C_CURSOR2PIC;
                timer = 8;
            }
            else
            {
                shape = C_CURSOR1PIC;
                timer = 70;
            }

Change it to this:
::: CODE :::
#ifdef VGAGRANIM
            shape ++;
            if (shape >= C_CURSOR1PIC+FRAMES4MENU)
            {
                shape = C_CURSOR1PIC;
                timer = ANIMSPEED4MENU;
            }
#else
            if (shape == C_CURSOR1PIC)
            {
                shape = C_CURSOR2PIC;
                timer = 8;
            }
            else
            {
                shape = C_CURSOR1PIC;
                timer = 70;
            }
#endif

That should do it. Smile

The code should now function bug-free. Smile

Edit: Added bugfixes in WL_MENU.CPP. Isn't it a mess? Well, at least it seems to work right. Confused
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 5:30 ago.

Topics: 163
Posts: 8152
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Fri May 20, 2011 10:02 pm
   Subject: Re: [Tutorial] Animating menu cursor & End Level BJ w/ 3+ fr
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Edit: Corrected silent crashes in WL_MENU.CPP; turns out it needed to cache/un-cache the images in Cursor3Pic through Cursor16Pic.
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Announcement: Wolf3d & Spear of Destiny Shareware SDL Downloads
Author: BrotherTank
10 14640 Tue Aug 24, 2010 10:18 am
dcbasic View latest post
No new posts Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 22956 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts [SDL-Help] Wall patches fix
Author: insurrectionman
0 1101 Tue Jul 15, 2008 11:12 am
insurrectionman View latest post
No new posts [Wolf4SDL Help] Inserting a second palette (like in SoD)
Author: Andy_Nonymous
10 3047 Mon Jun 02, 2008 3:59 pm
Adam Biser View latest post
No new posts [Help] Problem with Checkweaponchange function (wolf4sdl)
Author: Mortimer
4 3026 Sat May 17, 2008 11:26 am
Mortimer View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group