Using the drawingsurface to mimic an animation...

Started by Technocrat, Wed 02/09/2009 22:36:56

Previous topic - Next topic

Technocrat

Hopefully this is a "simple" enough question to go in the beginners' tech forum. Anyhow, for various reasons, I'm attempting to use the DrawingSurface to make an animation in the background - it's impossible to do with sprites because the game complains about having a maximum of 50 in the room.

My plan is to use DrawImage to put the image onto the room, then every few moments clear and refresh the DrawingSurface with the new "frame" of this animation based on an increasing int, in the room's repeatedly_execute. Unfortunately, what happens so far mostly results in the entire screen going pink, and the game "Waiting" all the time, while both frames appear at the same time on the screen. Being a complete idiot at DrawingSurface, can anyone point me in the right direction?


* EDIT - also, side question that might sort my problem out if it's changed. I'm still using version 3.02, and I'm limited to 50 sprites per room - has this limit been increased in 3.12?

Matti

The object limit hasn't been increased yet. I'd like to see that too, believe me!

I'm rather new to the draw surface/image stuff too, but can you post your code so we can see what the problem might be?

Wonkyth

Ah, screen going pink.
I had that problem.
Your problem is that you're clearing the screen transparent, and because there isn't anything behind the screen, it reverts to magic pink.
What you have to do is make a copy of the screen stored as a DrawingSurface datatype.
I think what you need is something like this:
Code: ags


DrawingSurface *backgroundCopy; //this is what is used to store the screen in it's normal state



//Drawing code

DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); //this is the temporary surface that we draw onto
if (backgroundCopy == null) backgroundCopy = surface.CreateCopy(); /*the first time the screen is drawn to, we'll make the backup copy so we can restore it each time*/
else surface.DrawSurface(backgroundCopy); /*if it isn't the first time, them we need to draw on a fresh screen to get rid of the last lot of drawing*/



That should handle the pink screen problem as well as the multiple frame problem, but what's this about the game "waiting"?
Are you using a blocking command in there or something?
Maybe you could post the code?

If it looks a bit complex, you could use a character...
"But with a ninja on your face, you live longer!"

SMF spam blocked by CleanTalk