conversion problem RawDraw -> DrawingSurface

Started by Rocco, Wed 16/07/2008 20:50:05

Previous topic - Next topic

Rocco

I have a module in the making, its nearly finished and works well with AGS 2.72.
Now i want to use it for a game with AGS 3.1 and got problems.

The structure of the module is:
Code: ags

function Init(int xxx)
{
    RawSaveScreen();                    
    RawDrawImage (15, 150, 152);
}


function a(....)
{
RawRestoreScreen();
}
function b(....)
{
RawRestoreScreen();
}

function repeatedly_execute() 
  {
       

     
     RawClearScreen(0);

     RawRestoreScreen();

     RawDrawImage (15, 150, 152);
}



works fine, now i replaced the old commands with the new ones and come in trouble

Code: ags

function Init(int xxx)
{

    DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
    DrawingSurface *backup = surface.CreateCopy();


       surface.DrawImage(X, Y, 455);
}


so  surface isnt available in the other functions, and i cant call it with

Code: ags

     surface.Clear();
     surface.DrawSurface(backup);

in other functions

when i try to generate the surface on top of the script outside the functions i get:

Quotedriving.asc(7): Error (line 7): cannot assign initial value to global pointer

monkey0506

Pretty much what the error says. You can't assign a default value. So:

Code: ags
DrawingSurface *surface, *backup;

function Init(int xxx) {
  surface = Room.GetDrawingSurfaceForBackground();
  backup = surface.CreateCopy();
  surface.DrawImage(X, Y, 455);
}

Rocco

big thx, the module works now again, in principle.

But the performance is much weaker then it was with 2.72.
the sprit i move around the screen, stucks every now and then,  :(
i didnt had this problem before with 2.72.

any suggestion how to speed up this thing a little bit.

SSH

Assuming nothing else is changing on the screen background, you only need to grab the original bg once right at the beginniong, rather than every game cycle.
12

Rocco

in the rep_execute i have:

Code: ags

surface.Clear(); 

surface.DrawSurface(backup);

surface.DrawImage(....);


when i move the sprit with DrawÍmage, i clear the sprite with surface.Clear, then i have to draw the bg again,
and then i draw the sprite on the new position.
Or is there a better solution for this task?

i found out, that it doesnt matter if the background is painted every Gamecycle or not, the weak performance comes from
surface.DrawImage(....);, and i cant do it without this command.

Are this functions slower now, then they was before with the RawDraw Commands?

SSH

I have to ask if there's a reason that you can't use an object, character, overlay or gui?
12

Rocco

well yes, there is a good reason,
but i dont want to explain that in detail cause i want to participate on the mags contest this month and dont want to talk to much about this intention.
but i will send you an pn, where you can see whats going on in detail right now.

i have a scrolling screen, and the game stucks when the sprite comes near a corner.

SMF spam blocked by CleanTalk