5 frame limit on background animations

Started by Trisk, Fri 04/05/2007 23:34:02

Previous topic - Next topic

Trisk

Yes, you can usually do small chunks animating like TLJ, but you can't do things like camera pans with that. There is also a point of animation where there is so much moving on the screen you might as well animate the whole screen as try to animate chunks of it. Ulisigi Ela was like that in Prodigal. You had everything but the sky flickering with light...there will be areas like that in Prodigal 2 as well.

Reguardless, this is getting far off topic. What this thread is supposed to be about is for people to weigh in whether they would like CJ to up the background frame limit.  :)

Ali

I don't think it's too off-topic to discuss the practicality of using objects for animating backgrounds. TLJ didn't just use small chunks of animation: up to half of the screen animates during the boat sequences. I doubt that would be feesable with an object, and that's why I'd support an increase in background frames.

Quote from: GarageGothic on Tue 08/05/2007 23:08:18
I didn't mean 'more efficient' in terms of framerate, I just meant achieving the same or better effect with simpler means. (I think the way AGS handles background animation doesn't cause framerate drops, but big room files means longer loading time between rooms, and more MB to download - and on machines with less RAM it could mean frequent swapfile access).

That's fair, but I'd choose a longer loading time over a low frame-rate. I think it would make sense for a game's author to be able to choose, provided the shortcomings of each method were well documented, or perhaps a warning popped up when a room's filesize became potentially cumbersome.

Elessar

Quote from: GarageGothic on Sat 05/05/2007 11:48:48Most likely you don't actually need to draw the entire screen due to GUI's or letterbox bars at the top and bottom. In that case you can cut down the sprites to the actual background area to save memory and speed things up, and then just change the (0,0) in the RawDraw command to the right coordinates.

If you're using this in multiple rooms with different offsets, instead of having to insert the code in each room with the offset hard-coded in, you can have something like this:

Code: ags
int backgroundspeed;
ViewFrame *backgroundviewframe;
int backgroundcounter;
int backgroundplaymode;
int offsetX;
int offsetY;

function AnimateBackground(int view, int speed, int loop, int offX, int offY) { //speed is the number of loops each frame will be displayed
   backgroundplaymode = loop; // 0 plays once, 1 keeps looping
   backgroundcounter = 0;
   backgroundspeed = speed;
   backgroundviewframe = Game.GetViewFrame(view, 0, 0);
   offsetX = offX;
   offsetY = offY;
   RawDrawImage(offsetX, offsetY,backgroundviewframe.Graphic);
   }

function StopAnimateBackground() {
   backgroundspeed = 0;
   }

function repeatedly_execute_always() {
  if ((backgroundspeed > 0) && (IsGamePaused() == 0)) {
     backgroundcounter++;
     if (backgroundcounter >= backgroundspeed) {
        int backgroundcurrentframe = backgroundviewframe.Frame;
	backgroundcurrentframe++;
	int backgroundcurrentloop = backgroundviewframe.Loop;
	if (backgroundcurrentframe >= Game.GetFrameCountForLoop(backgroundviewframe.View,backgroundviewframe.Loop)) {
	   backgroundcurrentframe = 0;
	   backgroundcurrentloop++;
           if (backgroundcurrentloop >= Game.GetLoopCountForView(backgroundviewframe.View)) {
              backgroundcurrentloop = 0;
              if (backgroundplaymode == 0) {
                 backgroundspeed = 0;
                 return;
                 }
              }
	   }
        backgroundviewframe = Game.GetViewFrame(backgroundviewframe.View, backgroundcurrentloop, backgroundcurrentframe);
	RawDrawImage(offsetX, offsetY, backgroundviewframe.Graphic);
	backgroundcounter = 0;
        }
     }
  }


Then when you use it in a room, import the functions as such:
Code: ags
import function AnimateBackground(int view, int speed, int loop, int offX, int offY);
import function StopAnimateBackground();


An example with an offset of 234 horizontally and 121 vertically is:
Code: ags
AnimateBackground(5, 2, 1, 234, 121);

GarageGothic

Nice addition, Elessar. The original purpose of the code was to play back full-screen transitions rather than animate parts of the background, so I didn't consider that a different offset for each screen might be useful. Thanks for the update.

SMF spam blocked by CleanTalk