Forms based game, you will have:
- A 4x4 array of square buttons. You will name each of these buttons differently, from Button_0_0 to Button_3_3
-A button which reads "New game"
-A non-editable text box where you will display feedback for the user
When the new game button is pressed:
- you will randomly choose the X coordinate [0-3] and Y coordinate [0-3] of the button that contains the "treasure". You will save these randomly chosen X and Y coordinates in the two int data members named treasureX and treasureY of the form (you have to add these two data members outside the callback but inside the form class code.
When the user presses one of the 16 buttons, you will:
-Check to see if the X and Y coordinate of the button matches the treasureX and treasureY coordinate. if so,
- You will report to the user "You found the treasure!", otherwise
-You will report to the user "Sorry there is no treasure here!"
This will require you to define 16 callback functions, one for each button
To get a random integer consider the following code
Random r = new Random();
int x = r.Next (100, 200);
which will set x between 100 and 199 inclusive (it will never return 200)
Loading

FroglegRank #1,020 · 1.9K reputationPosted Sep 7, 2012, 12:44 PM EDT
zero cool9 reputationPosted Sep 16, 2012, 2:30 PM EDT
Extend your program from assignment 1 to support the dynamic creation of a grid of 10x10 buttons which call the same callback method. Use the two dictionary data members to store the x and y coordinates of the buttons as you make them, so that the button click handler can determine the x and y coordinates of the button that was pressed
FroglegRank #1,020 · 1.9K reputationPosted Sep 16, 2012, 10:33 PM EDT
Dictionary
_dictionary.Add(x,y);
etc
private void btn_Click(object sender, EventArgs e)
{
Button button = sender as Button;
messageBox.Show(button.Location.ToString);
// here is part of what you need - we already created 16 dynamic buttons previously with
//same callback method
}
zero cool9 reputationPosted Sep 17, 2012, 7:20 PM EDT
But i have another problem that I'm having with an assignment. The PDF file will be attached. Would be a great help if you know how to do this.
kianu rieves39 reputationPosted Sep 17, 2012, 9:14 PM EDT
http://www.dapfor.com/en/net-suite/net-grid/features/graphical-filters-in-columns
FroglegRank #1,020 · 1.9K reputationPosted Sep 18, 2012, 12:47 AM EDT
zero cool9 reputationPosted Sep 18, 2012, 6:05 PM EDT
I done most of it i guess. Check out the zip file that i uploaded. Its going to have both the PDF of the assignment and the code.
THANK YOU!!!!