0% found this document useful (0 votes)
46 views2 pages

Puzzle Petchesi Iulian Explicatii

The document describes a puzzle game created in C# with 4 picture boxes containing images that must be dragged and dropped into their corresponding labels. It includes a start button to begin the timer, a counter to track the number of moves, and a timer that counts down from 60 seconds. When a picture box is dragged over its correct label and released, it will be automatically placed inside. If incorrectly placed, it will return to its starting position. The player wins if all pictures are in their right labels before time runs out.

Uploaded by

Darius Davidescu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

Puzzle Petchesi Iulian Explicatii

The document describes a puzzle game created in C# with 4 picture boxes containing images that must be dragged and dropped into their corresponding labels. It includes a start button to begin the timer, a counter to track the number of moves, and a timer that counts down from 60 seconds. When a picture box is dragged over its correct label and released, it will be automatically placed inside. If incorrectly placed, it will return to its starting position. The player wins if all pictures are in their right labels before time runs out.

Uploaded by

Darius Davidescu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PUZZLE C#

Pe formul creat am adaugat 4 picturebox-uri in care am incarcat imaginile care


pe urma vor trebui sa fie potrivite in labelurile lor specifice.
Elemente:
1) Butonul de Start - porneste timpul.
2) Numarul de mutari - la fiecare click pe o piesa se mareste numarul de mutari cu 1.
3) Timpul- la apasarea butonului Start se porneste timpul, timpul este presetat la 60
de secunde, cand timpul se termina apare un messagebox cu mesaj.

Explicatii:
1) Atunci cand o poza este pusa deasupra labelului corect ea va fi automat setata in
interiorul labelului:
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouse1 = e.Location;

}
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
pictureBox1.Left = e.X + pictureBox1.Left - mouse1.X;
pictureBox1.Top = e.Y + pictureBox1.Top - mouse1.Y;

if (Math.Abs(pictureBox1.Left - label1.Left) < 20 &&
Math.Abs(pictureBox1.Top - label1.Top) < 20)
{

pictureBox1.Location = label1.Location;
}

}


2) Daca picturebox-ul nu este in labelul corect el va reveni la pozitia initiala.

if (e.Button != MouseButtons.Left)
{
if (pictureBox1.Location != label1.Location)
pictureBox1.Location = new Point(659, 242);

}
3) Cand toate pozele sunt la locatia potrivita un MessageBox va aparea si te va
declara castigator.

You might also like