Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loading Sprites
#1
I've asked this once in the past, but couldn't find the post so...

Anyone know a tutorial on how to load sprites from a file into your program? A file that as more than one sprite on it? (I believe these are called tile-sets)
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#2
Here are some examples from my rogue-like (uses .14b):

Load the sprite strip:

Code:
Dim Shared As Any Ptr titem
titem = ImageCreate(480, 16)
Bload "gfx\item.bmp", titem

To display an individual item from the strip:
Code:
Dim As Any Ptr tp
tp = ImageCreate(16, 16)
Get titem,(32, 0) - (47, 15), tp
Put (x * 16, y * 16), tp, Trans

Basically I load the sprite strip image into an image buffer (first code block). Then when I display it (second code block), I use GET to extract the individual image from titem into tp. The (32, 0) - (47, 15) are the pixel locations of the individual image within titem. I then PUT tp to the screen. My images are 16x16 so my PUT has a 16 pixel offset.
Reply
#3
Hey thanks. Now when FB Bsaves a BMP file, can that file be opened in like paint? Also, how can I use a Bloaded sprite with SDL?
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply
#4
Yes.
Reply
#5
Quote:Also, how can I use a Bloaded sprite with SDL?
By converting it.. easiest way is to create an SDL buffer of the same bitdepth and size as the FB bload.. then copy the data over to the SDL buffer, and finally free the FB bload buffer.

I don't have any time now, but if you can't figure it out, I can whip up some sort of example sometime next week..
Reply
#6
Yeah, an example would be helpful. But only when you get the time.
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)