Drawing pixel/line skips. (SOLVED THANKS TO DKH)

Started by Dualnames, Sun 26/02/2012 16:33:32

Previous topic - Next topic

Dualnames

Code: ags

///WIRING  GUI////

wiringbomb=GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (gWiring.Visible==true) 
{
  if (wiringmode=="draw") 
  {
    if (wiringbomb!=null) 
    {
      if (wiringbomb==bwirea) 
      {
        //drawline
        if (Game.DoOnceOnly("tempmeasure"))
        {
          area=DynamicSprite.CreateFromExistingSprite(1229, true);
        }
        
        wirea=area.GetDrawingSurface();
        wirea.DrawingColor=64512;
        if (wirea.GetPixel(mouse.x, mouse.y)!=64512) 
         {
         wirea.DrawLine(mouse.x,mouse.y, (mouse.x), (mouse.y));
        }
        wirea.Release();
        bwirea.NormalGraphic=area.Graphic;
      }
      else 
      {
        //don't draw
      }
    }
  }
}
///WIRING  GUI////


wiringmode is a string
wiringbomb is a Guicontrol
area is a Dynamic sprite
bwirea is a gui button


The premise of this code is to draw on a gui button's graphic. And this works fine. The issue is that if mouse speed increases the drawing breaks. I'm not sure if that is coming across but the problem lies that if mouse speed is increased to a certain point, instead of drawing like this

____________

the drawing is like this
------------------

Aka it skips. Is there any way to fix that or somewhat help me limit the mouse speed? Supposedly the function should work. I even placed it a repeatedly_execute_always(). I even tried replacing line with pixel but the issue remains. I'm using line instead of pixel, because DrawPixel is a bit more slow.
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)

DoorKnobHandle

Store the mouse position every frame, then draw a line from the position where the mouse was last to the current position.

Dualnames

Something that needs to be mentioned is that I'm not using clicks of the mouse to draw the line, when the player clicks on a button wiringmode is set to "drawing", so I'm using the mouse position.
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)

DoorKnobHandle

I'm not sure if your post is a reply to my solution, but just to make sure, the method doesn't rely on you using clicks in any way, shape or form... :)

Let me know if I wasn't clear enough on how it works!

Dualnames

Somehow what you suggested, doesn't work. It still skips. Perhaps I did it wrong, so here goes what I did.
I apologize in advance if i did this amazingly wrong.
Code: ags

int gx,gy;

function repeatedly_execute_always() 
{
gx=mouse.x;
gy=mouse.y;

///WIRING  GUI////

wiringbomb=GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (gWiring.Visible==true) 
{
  if (wiringmode=="draw") 
  {
    if (wiringbomb!=null) 
    {
      if (wiringbomb==bwirea) 
      {
        //drawline
        if (Game.DoOnceOnly("tempmeasure"))
        {
          area=DynamicSprite.CreateFromExistingSprite(1229, true);
        }
        
        wirea=area.GetDrawingSurface();
        wirea.DrawingColor=64512;
        if (wirea.GetPixel(mouse.x, mouse.y)!=64512) 
         {
         wirea.DrawLine(gx,gy, (mouse.x), (mouse.y));
        }
        wirea.Release();
        bwirea.NormalGraphic=area.Graphic;
      }
      else 
      {
        //don't draw
      }
    }
  }
}
///WIRING  GUI////
}
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)

DoorKnobHandle

That:

Code: ags

gx=mouse.x;
gy=mouse.y;


Needs to be at the end of that function, then it should work!

Dualnames

Ohh...damn my stupidity. Thanks a lot man, I owe you one.  :D :D :D
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