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
FroglegPosted Sep 7, 2012, 4:44 PM
zero coolPosted Sep 18, 2012, 10:05 PM
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!!!!
FroglegPosted Sep 18, 2012, 4:47 AM
kianu rievesPosted Sep 18, 2012, 1:14 AM
http://www.dapfor.com/en/net-suite/net-grid/features/graphical-filters-in-columns
zero coolPosted Sep 17, 2012, 11:20 PM
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.
FroglegPosted Sep 17, 2012, 2:33 AM
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 coolPosted Sep 16, 2012, 6:30 PM
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