Slow Drawing, how can I improve it

Started by Dualnames, Sun 10/02/2019 14:26:02

Previous topic - Next topic

Dualnames

It is the iterations, Steve is doing way less of those.
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)

Scavenger

Wait a minute, I think I've done a similar effect in Terror of the Vampire. You don't even need to use PutPixel, because DrawCircle and CopyTransparencyMask are much, much faster. It ends up looking like this:
(It's at 2:25)

Basically, you draw two circles over each other (one to draw the ring, the other to cut out the middle), take a screenshot of the current screen, and cut it out with the mask. Then you blit that translucently to the screen with maybe just 1 pixel of random jitter to throw everything off, and the next frame, before you even remove the first bit, you take another screenshot and do the same thing. It's crude, but it's FAST. Also I'm really regretting not commenting all my code, but this was for a MAGS game so I didn't have much time to document it.
Code: AGS


// new module script
DynamicSprite *echosprite;
DynamicSprite *echosprite2;
DynamicSprite *echomask;
int angle = 1;
int echoX;
int echoY;
int echotimer=0;
bool doEcho = false;
int size;

static function VFX::EchoAt (int x, int y,int radius)
{
  echoX = x;
  echoY = y;
  echotimer = 0;
  doEcho = true;
  size = radius*2;
  echosprite = DynamicSprite.Create (radius*2, radius*2);
  echosprite2 = DynamicSprite.CreateFromExistingSprite (echosprite.Graphic);
  sldEcho.Min = 0;
  sldEcho.Max = radius;
  sldEcho.Value = 0;
  sldEcho.TweenValue (1.0, radius, eEaseLinearTween, eNoBlockTween);
  sldEcho2.Min = 0;
  sldEcho2.Max = radius;
  sldEcho2.Value = 0;
  sldEcho2.TweenValue (1.2, radius, eEaseInOutSineTween, eNoBlockTween);
}

function MakeEcho ()
{
  if (echotimer < size && doEcho)
  {
  echomask = DynamicSprite.Create (size, size);
  DrawingSurface *surf = echomask.GetDrawingSurface ();
  surf.DrawingColor = 15;
  surf.DrawCircle (size/2, size/2, sldEcho.Value);
  surf.DrawingColor = 0;
  surf.DrawCircle (size/2, size/2, sldEcho2.Value);
  surf.Release ();
  echosprite2 = DynamicSprite.CreateFromExistingSprite (echosprite.Graphic);
  echosprite = DynamicSprite.CreateFromScreenShot (320, 200);
  int newX = echoX-(size/2);
  int w=newX+size;
  int underflowX;
  int overflowX;
  int newY = echoY-(size/2);
  int h = newY+size;
  int underflowY;
  int overflowY;
  if (newX < 0)
  {
    underflowX =  newX * (-1);
    newX = 0;
  }
  if (newX+size > 320)
  {
    overflowX = (newX+size-320);
    w = 320-overflowX;
  }
  {
    
  }
   if (newY < 0)
  {
    underflowY =  newY * (-1);
    newY = 0;
  }
  if (newY+size > 200)
  {
    overflowY = (newY+size-200);
    h = 200-overflowY;
  }
  if (w+newX > echosprite.Width) 
  {
    newX = 0;
    w = echosprite.Width;
  }
  if (h+newY > echosprite.Height)
  {
    newY = 0;
    h = echosprite.Height;
  }
  echosprite.Crop (newX, newY, w, h);
  echosprite.ChangeCanvasSize (size, size, overflowX-underflowX, overflowY-underflowY);
  echosprite.CopyTransparencyMask (echomask.Graphic);
  Translucence.CreateOverlay (80, echosprite.Graphic, 128, 2, echoX-(size/2)-1-Random(1), echoY-(size/2)+1-Random(1)); //You can replace this with drawing at 50% transparency.
  //Translucence.CreateOverlay (81, echomask.Graphic, 128-echotimer, 2, echoX-(size/2), echoY-size/2);
  echotimer = sldEcho.Value;
  }
  else 
  {
    echotimer = 0;
    echoX = 0;
    echoY = 0;
    doEcho = false;
    Translucence.DeleteOverlay (80);
    Translucence.DeleteOverlay (81);
  }
}

Kweepa

#22
Quote from: Dualnames on Sat 16/02/2019 20:46:06
what a bastard
I love you too, Dual!
Smart idea with the mask, Snarky & Scavenger! Kind of hard to tell with the video compression but it sounds like it would work well. (And lovely art all round!)
Still waiting for Purity of the Surf II

Dualnames

Well, my issues with my code is i wanted to do a rectangle then i thought why not a circle, then proceeded to circle the rectangle instead of drawing a circle lol, also wow that is almost the exact same effect!
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)

SMF spam blocked by CleanTalk