More than 5 Background Frames

Started by Recluse, Mon 28/04/2008 02:51:10

Previous topic - Next topic

Recluse

I know this has been brought up before, but I'd like to bring it up again, because I don't see a viable work around.

In a game I'm working on, I need to be able to switch each room background between a total of _nine_ different images. Each one needs to be entirely different. Before anyone says anything, no, this isn't for an animation, I can't use objects, unless you suggest I use an object the size of the entire screen... Which is doable... Basically, there's a state-based system through which the room backgrounds need to be able to change, based on the value of a variable, which should be mutable at run-time.

The entire crux of my post is to ask Pumaman what purpose limiting the amount of backgrounds serves... I'm assuming it's a memory allocation issue, but it seems to me that it should have been made dynamic long ago.

Assuming that the 5 frame limit isn't going to be changed, I was curious as to any workarounds anyone might be able to suggest... I had thought of having more than one room per room.... but then things could easily get tricky. Please reply with any suggestions you may have. I had looked into the DynamicSprite functions, but I'm not up to date on their proper usage... can Dynamic Sprites be used to replace room backgrounds? If so, they may be a possible answer to my problem.
All your verbcoin are belong to us.

skuttleman

The only problem I could see with trying to use the background frames is that the game is going to try to conastantly cycle through them, so you'd have to constantly call the Room.SetBackgroundFrame function in order to maintain any level of control over which background is being displayed.

Read more about the Dynamic Sprites and I would use the Room.GetDrawingSurfaceForBackground function (which would mean you'd need all the extra backgrounds loaded into sprite slots - well, you could load them from files, but you'd have to distribute those files with the game, so sprites would be better.)

Hope this helps.


GarageGothic

#2
Check out the DrawingSurface functions. This allows you store background frames as sprites and change the background graphics when needed.

Code: ags
DrawingSurface *backgroundsurface = Room.GetDrawingSurfaceForBackground();
backgroundsurface.DrawImage(0,0,spriteslot);
backgroundsurface.Release();


Just replace "spriteslot" with the number of your background sprite.

Edit: Wrote this while skuttleman posted his entry. Just to clarify, you do NOT need to use DynamicSprites unless you actually create new graphical content (such as drawing lines an whatnot onto the background) and need to store them for later use. As longs as you just paste an already existing sprite to the background, DrawingSurface should be enough.

Pumaman

Originally this was limited to 5 in order to make sure that room loading times didn't take too long -- 6 years ago when AGS 2 was first released, if you had 10 backgrounds the room would take ages to load.

Nowadays it's not such a problem so it could probably be increased.

Dualnames

Actually I think no need for it. Two reasons it gets slow when transparency guis end up together at the screen, and you can use an object and merge it into background
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Recluse

Pumaman: Please... if you're still working on new builds, I would suggest to add some sort of increase into the next release. Perhaps even an option in the Game Preferences to allow the developer to specify the amount of frames per room in each game. This could decrease loading times on slower machines, if the dev only plans on using one background, and allows developers to use more than 5 frames total, without going through a workaround.

GarageGothic: Thanks for that code. You can bet I'll make liberal use of it.
All your verbcoin are belong to us.

SMF spam blocked by CleanTalk