Public Group

Sprites

This topic is 2948 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello,

I just started game programming and I am also glad to be here.
for example if 1 bmp image with a lot of frames inside I don't get how you could for example get 1 frame in a bitmap while its only 1 image,unless for example you get the rect coordinates of next frame itself could someone shed some light for me please.
thanks.

Share on other sites
Quote:
 unless for example you get the rect coordinates of next frame itself

Why can't you get the rect coordinates?

If I have an image that's 100 pixels wide and 10 pixels tall, and my individual frames are 10 by 10 pixels, then I can just go:
numberOfFramesInImage = sizeOfImage / sizeOfFrame
If my images are 10 by 10 pixels, and I want to get frame number 3, I can go:
positionOfFrame = frameNumber * sizeOfFrame

//Psuedo-code:
imageWidth = ??imageHeight = ??frameWidth = ??frameHeight = ??-----------------------maxNumberOfFramesHigh = imageWidth / frameWidth;maxNumberOfFramesWide = imageHeight / frameHeight;frameX = 5; //I want to get the 5th frame horizontally,frameY = 3; //and the 3rd frame vertically.//This is the pixel position of the start of the frame, from inside of the image.positionX = frameX * frameWidth;positionY = frameY * frameHeight;GetFrameFromImage( positionX, positionY, frameWidth, frameHeight )

What API or library are you using (SDL, SFML, OpenGL, DirectX, etc...)? What programming language?

Welcome to GameDev.net, btw. [smile]

[Edited by - Servant of the Lord on October 21, 2010 2:21:10 AM]

Share on other sites
Quote:
Original post by Servant of the Lord
Quote:
 unless for example you get the rect coordinates of next frame itself

Why can't you get the rect coordinates?

If I have an image that's 100 pixels wide and 10 pixels tall, and my individual frames are 10 by 10 pixels, then I can just go:
numberOfFramesInImage = sizeOfImage / sizeOfFrame
If my images are 10 by 10 pixels, and I want to get frame number 3, I can go:
positionOfFrame = frameNumber * sizeOfFrame

//Psuedo-code:
*** Source Snippet Removed ***

What API or library are you using (SDL, SFML, OpenGL, DirectX, etc...)? What programming language?

Welcome to GameDev.net, btw. [smile]

I see now I understand now you calculate the frame by getting its rectangle coordinates.

just got confused about dealing with Sprites because I have always dealed with a bitmap image that had only 1 frame while programming normal windows apps.

I am currently learning DirectX language C,so hopefully I will get into the realm of Game programming soon :D.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• Forum Statistics

• Total Topics
633326
• Total Posts
3011373
• Who's Online (See full list)

There are no registered users currently online

×

Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!