Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use sprite sheets?
#11
(09-09-2022, 02:34 PM)TerryRitchie Wrote: My preferred method is to load the sprite images into an array.

Hi Terry,

So I tried loading graphics via sprite sheet in 2 different ways:

1) Just loading the sprite sheet and referencing the sprites I needed.

2) Loading the sprite sheet and adding the sprites into an array (your preferred method).

Option 2 is indeed nice if you want to have greater control over which frames get shown. Using this method, I was able to easily "rewind" an animation.

However, from a game design standpoint, it needs to be pointed out that option 2 comes at the cost of load time.

When I loaded just the sprite sheet (option 1), I could get all the graphics in the animation to show in about 1.15 seconds.
Option 2 increased the load time to 2.25 seconds.
Reply
#12
TheBOB did this kind of work "old school" by building his own bitmaps back in the late 1980's. Now that's a lot work...

TheBOB playing cards made for Solitaire3: https://qb64phoenix.com/forum/showthread.php?tid=185

In regard to cutting and aligning individual images to and from sprite sheets, I recall years ago running across some freeware that did that for you. Search sprite sheet maker and you'd probably still find programs that can do that for you.

Anyway, just chiming in with some more info, as I see you've already read a series of solutions posted. Great to have you back in the community, btw, and best wishes on completing your game.

Pete
Reply
#13
(09-12-2022, 10:31 AM)40wattstudio Wrote:
(09-09-2022, 02:34 PM)TerryRitchie Wrote: My preferred method is to load the sprite images into an array.

Hi Terry,

So I tried loading graphics via sprite sheet in 2 different ways:

1) Just loading the sprite sheet and referencing the sprites I needed.

2) Loading the sprite sheet and adding the sprites into an array (your preferred method).

Option 2 is indeed nice if you want to have greater control over which frames get shown. Using this method, I was able to easily "rewind" an animation.

However, from a game design standpoint, it needs to be pointed out that option 2 comes at the cost of load time.

When I loaded just the sprite sheet (option 1), I could get all the graphics in the animation to show in about 1.15 seconds.
Option 2 increased the load time to 2.25 seconds.

Yep, there are trade-offs. Have you ever noticed when big name games start they usually have a few logos that fade in and out highlighting the companies involved in the project. What you don't see is during that time the assets (images, sounds, etc..) are getting loaded behind the scenes and processed. Many times during cut scenes in games the same is happening. With a little clever coding the load times can be made irrelevant.

I still prefer placing sprites into arrays because in the long run code becomes efficient. It's faster to reference and index number for an image than it is to calculate the locations on a sprite sheet and have _PUTIMAGE clip the image for you each time you need it. My original Sprite library uses referencing and although it works well it gets painfully slow when needing to access many images over and over again.

And then another issue arises when you need to rotate or zoom a sprite. You need to reference it, put it into at least a temporary image holder, rotate and/or zoom the sprite, then finally use it on the screen. I feel it's much better to pre-calculate all the zooming and rotating you'll need and put those images into an array. During that precalc period come up with a nifty logo sequence when your game starts to mask whats going on.
Reply




Users browsing this thread: 1 Guest(s)