Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Rocco on Wed 16/07/2008 20:50:05

Title: conversion problem RawDraw -> DrawingSurface
Post by: Rocco on Wed 16/07/2008 20:50:05
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:

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


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


     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
Title: Re: conversion problem RawDraw -> DrawingSurface
Post by: monkey0506 on Wed 16/07/2008 21:00:34
Pretty much what the error says. You can't assign a default value. So:

DrawingSurface *surface, *backup;

function Init(int xxx) {
  surface = Room.GetDrawingSurfaceForBackground();
  backup = surface.CreateCopy();
  surface.DrawImage(X, Y, 455);
}
Title: Re: conversion problem RawDraw -> DrawingSurface
Post by: Rocco on Wed 16/07/2008 21:52:25
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.
Title: Re: conversion problem RawDraw -> DrawingSurface
Post by: SSH on Wed 16/07/2008 22:07:37
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.
Title: Re: conversion problem RawDraw -> DrawingSurface
Post by: Rocco on Wed 16/07/2008 22:26:01
in the rep_execute i have:


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?
Title: Re: conversion problem RawDraw -> DrawingSurface
Post by: SSH on Wed 16/07/2008 22:36:39
I have to ask if there's a reason that you can't use an object, character, overlay or gui?
Title: Re: conversion problem RawDraw -> DrawingSurface
Post by: Rocco on Wed 16/07/2008 22:44:22
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.