Question Drag and Drop picture boxes

Habster

New member
Joined
Jan 5, 2021
Messages
2
Programming Experience
Beginner
Hello. I'm looking for a simple drag and drop game. The main idea is to show some simple mathematic equation like 2+2 and what I want to do is to show 3 random answers (from 1 to 9) where one of them is correct. To answer the equation, I want the picturebox to be dropped into specified square and when the answer is right, we are getting +score. If the answer is wrong, we get some -score. In what way I can make a value of specified pictureBoxes (I have generated 9 graphics (numbers 1-9)) and generate them randomly but always with one correct answer?
 
What have you tried and where are you stuck? If you search the web for how to perform drag and drop operations in WinForms then you'll find plenty of information. You should that research, put what you learn into practice and then we can help you if and when you encounter an actual issue.
 
In what way I can make a value of specified pictureBoxes (I have generated 9 graphics (numbers 1-9))
Why do you even need pictureboxes? What's wrong with a standard Label with a number in it?
 
I mean, I want to generate some random math equation and 3 answers where one of them is correct. I want the answer to be able to drag into the box with the answer. How can I link the generated equation with one right answer and generate two bad? And how Can I connect the field for the answer with the generated equation?
label 1 and 2 are generated randomly numbers from 1 to 9. They can be multiplicated or added, depending on the level of the game.
After that, I want to set three values at the buttons ( i don't know if it's possible to make the integer values of the buttons (maybe you can suggest something that is easier to set value to?) and two values are incorrect, one is correct. If i drag the right answer into the square and drop it there I want to execute an action that will check if the dropped value is the answer for the generated equation. If it is , score should be +10, and if it's wrong, score should be -5. I want the game to be ended when I reach for example 50 points. I have no idea how to connect these three things- the equation, the answers and the answer box.
 

Attachments

  • draaggg.png
    draaggg.png
    5.8 KB · Views: 24
In WinForms, all controls have Tag property that can hold anything. So if you don't want to keep re-parsing the labels' Text property to see what values are there, you can store the actual value in Tag.

Personally, I think that you are making things much harder than you have to by doing drag and drop. If you want the user to pick an answer out of multiple choices, setup a radio button group with the possible answers, and let the user select their answer.
 
Back
Top Bottom