Can someone explain the concept of bitmap animations to me

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 42
Reputation: Pikachumanson is an unknown quantity at this point 
Solved Threads: 1
Pikachumanson's Avatar
Pikachumanson Pikachumanson is offline Offline
Light Poster

Can someone explain the concept of bitmap animations to me

 
0
  #1
Mar 4th, 2009
What I want to do is take my rpg man sprite and understand how I can access each of his eight animations with methods. I've looked at code that does something like this but I'm not quite getting it. Right now, I got my guy to do two seperate animations from two separate bmps and he's facing forward in every direction he goes.So it looks like he's walking forward all the time. I guess what I am asking is how do I go about accessing all eight of his animations from a single bmp and assign them to the direction I want that animation to go to?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Can someone explain the concept of bitmap animations to me

 
0
  #2
Mar 5th, 2009
Well, your bmp, is it done the standard way of having in effect the 8 pictures side by side in say a 2 row, 4 column format? If so you have to copy the relevant "frame" out of that picture and place it on the screen
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 42
Reputation: Pikachumanson is an unknown quantity at this point 
Solved Threads: 1
Pikachumanson's Avatar
Pikachumanson Pikachumanson is offline Offline
Light Poster

Re: Can someone explain the concept of bitmap animations to me

 
0
  #3
Mar 5th, 2009
Yeah I saved it in 24-bit bmp format. All a straight line of 8 individual animations. So what do I do? I know I'm supposed to make a private int for the frame variable.

so should I have something like this.

private int frame = 0;

or something like this?

Rectangle[] rectFrames = new Rectangle[8];

also I know I should have my bmp's width and height. width = 31 height = 43
But where I get confused is when I try to assign animations to the direction I want my character to move. I want two animations for each direction I want my little man to move in. So basically, I have two questions. One how do I access my frame animate from one bmp seperately and two where do I put these methods so i can get the desired effect?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Can someone explain the concept of bitmap animations to me

 
0
  #4
Mar 5th, 2009
As I said you need to copy out the relevant "frame" from within your big picture. Doing it into an array is often easiest to code with later.

so if your picture was in the format

1 2 3 4
5 6 7 8

(numbers representing your man in a frame)
you use some maths, to extract each of the bitmaps (either by calculating the size of the picture given the original size of the image and the number of "frames" wide and tall, or by specifying them, and then copy that section into a new picture in your array of mini pictures constituting a frame.

Then to play the animation you would use a timer (or similar) to change the image to the next in rotation every interval you pick.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 42
Reputation: Pikachumanson is an unknown quantity at this point 
Solved Threads: 1
Pikachumanson's Avatar
Pikachumanson Pikachumanson is offline Offline
Light Poster

Re: Can someone explain the concept of bitmap animations to me

 
0
  #5
Mar 5th, 2009
Ok that explains quite a bit for me. Thank you Liz. I will get to working on the code right.

I believe this bit of code here is the heart of what I want to do.

for(int i=0; i< nFrames; i++)
{
Point pt = new Point(Hero_width * i, 0);
frames[i] = new Rectangle(pt, new Size(Hero_width, Hero_height));
}

Am I on the right track?

And while I'm at it here is the timer function I've written:
private void TimerSprite_Tick(object sender, System.EventArgs e)
{
if(currentframe >= nFrames - 1)
{
currentframe = 0;
}
else
{
currentframe++;
}
}

I've gotten it so that I can get bmp file to run through all of its animations now I gotta figure out how to assign those animations to each key.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Can someone explain the concept of bitmap animations to me

 
0
  #6
Mar 5th, 2009
There are ways you could improve it, but its on the right track.

Something you might want to investigate are the "mod" or % maths functionality
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC