Archived

This topic is now archived and is closed to further replies.

rob64464

Question for C# masters!

Recommended Posts

Hello, I am making a Word Game and I am stuck on an efficient way of detecting clicks on a letter. Let me explain A S D F G A Q P J A A S D F G F A S W E R T Y A S F H G H J ok its like the above but 7x7. What I want to do is make a boggle tyoe grid. So you can only select the boggle words which are next to each other 1 = can be clicked A S D F G A Q P J A A 1 D F G F A S 1 1 1 T Y A S F 1 f H J So how would I make this game. The question may look confusing but all I basically am saying is how do u make the grid in a boggle game? [in a windows form application] Thanks, Rob

Share this post


Link to post
Share on other sites
If your board''s going to be a pretty small grid, you could just make one control for each cell of the grid. In your case, you''d make a bunch of labels probably, set their font to something pretty big and their alignment to center, then you could just consume their MouseDown events to detect when the user clicked one.

However, this is a pretty bad way of doing things. I tried doing something similar while writing the game Go, which has a 19 x 19 board, and I blew up the debugger when I tried creating all 19 * 19 = 361 controls, and this was a fast computer w/ 512 mb ram.

So, what I ended up doing was inheriting a Board class from Panel (I think... this was a year and a half ago), overloading its Draw() (or Paint(), or whatever Microsoft calls it) function and putting in code to draw the entire 19x19 board, and overloading its OnMouseUp() function to figure out which square was clicked on, then take appropriate action. Figuring out which square was clicked on is easy -- if you know how big your squares are, you just divide the mouse-click''s x location (in coordinates relative to your control) by the width of your squares to figure out how many squares from the left edge you are, and divide the mouse''s y location by the height to figure out how many squares you are down from the top.

Share this post


Link to post
Share on other sites
Sorry I am so late replying to this email it''s just that I have been tied down by trying to get another server up and running and now I have come back to my nighmare problem its 7 x7 so there is 49 pictureboxes in total meaning I will be there for ages So what your saying is that I should do this:

//box1 click
{
Box2.Enabled = true;
box6.Enabled = true;

allotherboxes.Enabled = false;
}

Share this post


Link to post
Share on other sites