I have some picture box and I don't want my main character to touch it like to stop moving

28 Views Asked by At
private void Form1_KeyDown(object sender, KeyEventArgs e)
{    
    if (e.KeyCode == Keys.A)
    {
        if (pbMainBox.Location == PictureBox.Location)
        {
            // I leave this if blank because I don't want to do anything when I press A
        }
        else
        {
            // here in else I like if it anywhere it can move 
            // but if it in the PictureBox location it can't move
            pbMainBox.Location = new Point(pbMainBox.Location.X -2, pbMainBox.Location.Y);
        }
    }
}

pbmainBox is my main box and what I name it PictureBox it's the border

0

There are 0 best solutions below