Animation

This is a discussion on Animation within the Windows Programming forums, part of the Platform Specific Boards category; Hi: Assume that there is a bitmap which contains all the attitudes of a creature,and I load each attitude in ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    173

    Unhappy Animation

    Hi:
    Assume that there is a bitmap which contains all the attitudes of a creature,and I load each attitude in each frame and wanna play the animation,the problem is that how can I play the selected frames?for instance,like walking.

  2. #2
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hmm, i dont know a direct answer to you question, but i would suggest putting your frames into an animation. Then refer to Ken Fitlikes tutorial, its neat ken!. He shows you how to display an animation in one of his tutorials.

    http://www.foosyerdoos.fsnet.co.uk/


    Hope that helps
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    173
    Sorry,man,I forgot to say that I use the DirectX within Win 32 to create the animation.

    I think there is one way: To create another DirectDraw surface array to contain the selected frames,then play them one by one,hmm i am gonna try this, or do you have any idea else?

    Thanx alot !!!
    Don't laugh at me,I am just a SuperNewbie.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>I forgot to say that I use the DirectX within Win 32 to create the animation<<

    Then my wee, humble website is probably the last place on earth you want to look.

    I think there is a directX equivalent of NeHe's 'everything you ever wanted to know about openGL but were afraid to ask'. I think it's:

    http://nexe.gamedev.net/

    Thanks for the endorsement, TNT, - the cheque is in the post
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    What I normally do is use a pair of int's that represents the
    current frame of animation (ie: xPos, yPos). Then I cycle through
    them and populate a temp RECT with the values. The temp RECT
    is the RECT that I'm BltFast'ing from.

    here's a generic example (5 frame animation, 32 x 32 sprites):
    Code:
    int xPos, yPos;
    bool Animate, LeftFootFirst;
    
    //in the game loop
    if(Animate)
    {
      DoAnimation();
    }
    
    void DoAnimation()
    {
       switch(xPos)
        {
         case 0:
          {
            xPos=1;
            LeftFootFirst=true;
          }break;
         case 1:
         case 2:
         case 3:
         {
           if(LeftFootFirst)
            {
              xPos++;
            }
           else
           {
             xPos--;
           }
         }break;
        case 4:
         {
           xPos=4;
           LeftFootFirst=false;
         }break;
      }
    }
    
    //in my blitting routine
    RECT rcTemp;
    SetRect(&rcTemp,xPos*32,yPos*32,(xPos*32)+32,(yPos*32)+32);
    lpddsBack->BltFast(rcSprite.x,rcSprite.y,lpddsSprite,&rcTemp,DDBLTFAST_WAIT);
    This is a generic example. I normally use classes that would hold
    my RECTs, etc., but hopefully this will give you the idea.
    Oh and I didn't bother populating the yPos variable, but what I
    normally do is have my sprites in rows. ie: the top row of the
    bitmap is the walking frames, the next row down is the shooting
    frames, the 3rd row down is the dying frames, or whatever.... So
    I populate the yPos based on what action I'm telling the "unit" to
    perform.

  6. #6
    Registered User WayTooHigh's Avatar
    Join Date
    Aug 2001
    Posts
    101
    here's an example in API i did awhile ago.
    Attached Files Attached Files
    Sometimes, the farthest point from the center is the center itself.

    Your life is your canvas, it's only as beautiful as you paint it.

  7. #7
    Registered User
    Join Date
    Aug 2001
    Location
    Melbourne, Australia
    Posts
    92
    I, personally, would create one image with lots of different frames all side by side, then blit from the appropriate spot.

    -out-
    Jeff
    psychobrat at gmail

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opengl walking leg animation
    By Bobby230 in forum C Programming
    Replies: 3
    Last Post: 03-05-2006, 03:41 PM
  2. Threads in MFC
    By VirtualAce in forum Windows Programming
    Replies: 4
    Last Post: 12-28-2005, 06:03 PM
  3. Animation class not working
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 03-02-2005, 06:48 AM
  4. animation timing
    By Eber Kain in forum Game Programming
    Replies: 2
    Last Post: 06-29-2004, 07:32 PM
  5. 3D animation (difficult?)
    By maes in forum Game Programming
    Replies: 3
    Last Post: 09-08-2003, 11:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21