示例#1
0
        public override void Update()
        {
            if (mouse.Acquire().IsSuccess)
            {
                mousestate = mouse.GetCurrentState();

                oldTrigger = Trigger;
                Trigger    = mousestate.IsPressed((int)MouseObject.Button1);

                if (timer > 0)
                {
                    timer--;
                    pixelX = ((Cursor.Position.X - winPosX) * 256) / videoW;
                    if (pixelX < 0 || pixelX >= 256)
                    {
                        State = false;
                        return;
                    }
                    pixelY = ((Cursor.Position.Y - winPosY) * scanlinesCount) / videoH;
                    if (pixelY < 0 || pixelY >= scanlinesCount)
                    {
                        State = false;
                        return;
                    }
                    //System.Console.WriteLine(pixelX + ", " + pixelY);
                    for (int x = -15; x < 15; x++)
                    {
                        for (int y = -15; y < 15; y++)
                        {
                            if (pixelX + x < 256 && pixelX + x >= 0 && pixelY + y < scanlinesCount && pixelY + y >= 0)
                            {
                                c     = NesEmu.GetPixel(pixelX + x, pixelY + y);
                                r     = (byte)(c >> 0x10);            // R
                                g     = (byte)(c >> 0x08);            // G
                                b     = (byte)(c >> 0x00);            // B
                                State = (r > 85 && g > 85 && b > 85); //bright color ?
                            }
                            if (State)
                            {
                                break;
                            }
                        }
                        if (State)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    State = false;
                }
                if (!Trigger && oldTrigger)
                {
                    timer = 6;
                }
            }
        }
示例#2
0
 public override void Update()
 {
     oldTrigger = Trigger;
     Trigger    = Mouse.IsButtonPressed(MouseButton.PrimaryButton);
     if (timer > 0)
     {
         timer--;
         pixelX = ((Mouse.MousePosition.X - winPosX) * 256) / Program.VIDEO.ScreenWidth;
         if (pixelX < 0 || pixelX >= 256)
         {
             State = false;
             return;
         }
         pixelY = ((Mouse.MousePosition.Y - winPosY) * Program.VIDEO.scanlines) / Program.VIDEO.ScreenHeight;
         if (pixelY < 0 || pixelY >= Program.VIDEO.scanlines)
         {
             State = false;
             return;
         }
         //System.Console.WriteLine(pixelX + ", " + pixelY);
         for (int x = -15; x < 15; x++)
         {
             for (int y = -15; y < 15; y++)
             {
                 if (pixelX + x < 256 && pixelX + x >= 0 && pixelY + y < Program.VIDEO.scanlines && pixelY + y >= 0)
                 {
                     c = NesEmu.GetPixel(pixelX + x, pixelY + y);
                     r = (byte)(c >> 0x10);
                     // R
                     g = (byte)(c >> 0x08);
                     // G
                     b = (byte)(c >> 0x00);
                     // B
                     State = (r > 85 && g > 85 && b > 85);
                     //bright color ?
                 }
                 if (State)
                 {
                     break;
                 }
             }
             if (State)
             {
                 break;
             }
         }
     }
     else
     {
         State = false;
     }
     if (!Trigger && oldTrigger)
     {
         timer = 6;
     }
 }