Sprites and different formats?

This is a discussion on Sprites and different formats? within the Game Programming forums, part of the General Programming Boards category; I have a question that I have been searching for quite some time. Usually when I include sprites in my ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    118

    Sprites and different formats?

    I have a question that I have been searching for quite some time. Usually when I include sprites in my programs I do them from scratch. I mean I actually type them in number format into a two dimentional array. I know this probably sounds crazy to most, but it is the only way I know how. I have not been programming long, and have seen many sprite editors for download, but they always save the sprite as a strange file type which I do not know how to use. My question is, is there a Sprite editor that will created a sprite and give me the information for it in a two dimentional array. I mean actually give me the numbers. I have never used a file to load a sprite from, and I understand that is the way it is done. If anyone could shed some light It would be greatly appreciated. And also if you could let me know how to include sprites in programs the proper way that would be great.

    -a confused novice programmer!
    "The distinction between past, present and future is only an illussion, even if a stunning one."
    -Albert Einstein

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well it actually doesn't matter how you store your sprites. Bitmaps are good and easy. JPEGs are good too. The main concern with a newbie is to just be able to get the sprite from the file to the screen. So I'll give a quick run down of bitmaps. You can find the actual file format on msdn.microsoft.com. Anyways, like most formats bitmaps store pixels in a 1d array. There is a file header that gives you information such as the width, height, and the number of bits per pixel.

    Long story short, there are a ton of libraries for reading common files such as bitmaps. Bitmaps can also be stored within a exe.

  3. #3
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    I just store my sprites in one bitmap, then load them into seperate sprites.

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    I've made a palette library for SDL, which will take a bitmap file containing multiple entries, or "sprites" and load them. Then you can access each individual one by passing an index. If you want it, PM me.

    Most libraries have built-in bitmap loading routines.. like sdl has SDL_LoadBMP() and OpenGL has something like GLaux_LoadBMP() (I know that's not correct).

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    118
    What is a good sprite format to use. I see stuff like RLE and others. The compiler I am using is Borland C 3.1. It's pretty old but free and easy to use for a novice. Which format would work best in 3.1. Also, can you draw your sprite with Paint that comes with the Windows OS, and how does it have to be saved? One other question, is it possible for a BMP to be changed to a 1d array that can be cut and past into a program? Thanks.
    "The distinction between past, present and future is only an illussion, even if a stunning one."
    -Albert Einstein

  6. #6
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    The format that is _best_ for a sprite is the format that meets the needs of your program and you. If you can canabalize someone elses code and use their format, fine-- as long as it meets your needs.

    A sprite, for _any_ program is going to have the following basic elements:

    pixmap - 1 to n bits deep, color image
    bitmap - 1 bit deep, mask
    rectangle - bounding box
    palette - sprite's colors


    If you are handling x,y coords manually, that is an _old_ style way of doing things. move onto using bitmaps and pixmaps.
    It is not the spoon that bends, it is you who bends around the spoon.

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    69
    SDL supports transparency in files like, say, PNG, if they have an alpha channel, which makes it real easy on you for your sprites.

    I'd be interested in that library/thingy that was mentioned above, just to see how it works.
    D. Olson
    The Mandrake eXPerience
    Battle Pong

    IDE: kate 2.0
    Compiler: gcc 3.2
    Graphics/Input/Net: SDL 1.2.5 (pdf)
    3D Audio: OpenAL (pdf)


    I am a signature virus. Please add me to your signature so that I may multiply

Popular pages Recent additions subscribe to a feed

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