Word Game Soloution C#
I am making a word game and i drew a picture out for you to see if you can help. If you dont understand please tell me!
Thanks,
Rob
This is extremely vague!
If the boxes are stored in a 2d array, then you can just check all 4 surrounding boxes and see if they are a ''not'' before allowing the player to move in that direction.
PS I dont understand what you are talking about so my advice may be wrong. Sorry
If the boxes are stored in a 2d array, then you can just check all 4 surrounding boxes and see if they are a ''not'' before allowing the player to move in that direction.
PS I dont understand what you are talking about so my advice may be wrong. Sorry
You have the X and Y of the latest selected box. Now the next selected box can only be X-1,Y / X+1,Y / X,Y-1 / X,Y+1 (and probably not the one where you came from before).
Shouldn''t be too hard.
Shouldn''t be too hard.
I''ll explain more. Imagine you have a word search and the word is this
H <- notice this
W
O
R
D
S
E
A
R
C
Well at the moment they could make that word because they can select any box in a line. So what I want it to do is when U click O - C it disables the H picturebox so they cannot make word search. You get me? But of course there is going to be 49 boxes so I can use
private void Box3()
Box1.Enables = false; can I because the code would get far to big! So any ideas?
H <- notice this
W
O
R
D
S
E
A
R
C
Well at the moment they could make that word because they can select any box in a line. So what I want it to do is when U click O - C it disables the H picturebox so they cannot make word search. You get me? But of course there is going to be 49 boxes so I can use
private void Box3()
Box1.Enables = false; can I because the code would get far to big! So any ideas?
Post some code. It sounds like you are about to do something like creating a variable for each cell:
Box1
Box2
Box3
barf-o-rama! Create an array for this. I don't know the VB syntax, but look up arrays. Then you just have one variable that has many cells and you access a particular cell by index, Something like this, again excuse the syntax:
Dim Box(32) as Integer 'creates an array of Integers with 32 elements
Box(0) = 2 'puts the value 2 in slot 0
Box(14) = 6 'puts the value 6 in slot 14
Box(3) = 5 'see the pattern yet?
EDIT: OK duh, read the title, C#
Arrays in C# are similar to VB:
int Box[] = new int[32]; //creates an array of 32 integers
Then you access each element like so:
Box[4] = 100;
int x = Box[8];
and so on.
[edited by - CodeMunkie on March 22, 2004 12:15:50 PM]
Box1
Box2
Box3
barf-o-rama! Create an array for this. I don't know the VB syntax, but look up arrays. Then you just have one variable that has many cells and you access a particular cell by index, Something like this, again excuse the syntax:
Dim Box(32) as Integer 'creates an array of Integers with 32 elements
Box(0) = 2 'puts the value 2 in slot 0
Box(14) = 6 'puts the value 6 in slot 14
Box(3) = 5 'see the pattern yet?
EDIT: OK duh, read the title, C#
Arrays in C# are similar to VB:
int Box[] = new int[32]; //creates an array of 32 integers
Then you access each element like so:
Box[4] = 100;
int x = Box[8];
and so on.
[edited by - CodeMunkie on March 22, 2004 12:15:50 PM]
The question is what exactly does this have to do with C# ? The title is misleading.
As for selection you can disable the ones that shouldn''t be able to be selected with an extended or drived class that has an additional property to help you decied if it is so. Throwing an exception in the code if its in "not" category. Catching it displaying a Error to the client, clearing the selection.
As for selection you can disable the ones that shouldn''t be able to be selected with an extended or drived class that has an additional property to help you decied if it is so. Throwing an exception in the code if its in "not" category. Catching it displaying a Error to the client, clearing the selection.
what does it have to do with c#? Let me see? hmmm???? MAYBE I AM MAKING THE GAME IN C#!!!!!!!! Maybe thats got something to do wtih it?
Well, yes and no. I guess to keep it simple you could just make an array of PictureBoxes and use the Tag property to store info about the box. Not the most elegant solution, but simple enough. And afterburn said what he said because up til now you have not asked anything C# specific.
Well maybe so but the question is not directly related to C#. Its related to data or object structure. The language is not relevent in this context.
As you can see this could be built in C++ or VB or any other language. so the constructs of the implementation is not relevent to what your problem is.
The problem is more related in How do I make sure they do not select certain boxes.... I know which ones are disabled but how do I go about coding the issue.
The real issue here can be solved with a 2d array.
PictureBox[][] aryPic = new PictureBox[7][7] //49 Picture Boxes
//not had to make a 2d array as of yet in C# so this might be incorrect syntax. Only used ArrayList and other collections.
You might also note that your image shows a row of 6. and a cols of 7. = 42 not 49.
if you derive your a class from the picture box you can extend so properties.
class MyPicBox: PictureBox
{
bool selectable;
public MyPicBox():base()
{
selectable = true;
}
public bool IsSelectable
{
get{
return selectable;
}
set{
selectable = value;
}
}
}
This way you can just add additional logic to the object that can also display data visually to the user. Otherwise your creating multiple objects like an array of items to hold your pictures and another to hold your "selectable" value;
Maybe you need to study the underlying principals concerning design OO. The idea is to encapsulate as much as possible.
While creating the fewest objects to handle such.
So look at your question again as you do not specify anything that is language specific...
[edited by - afterburn on March 22, 2004 1:15:35 PM]
[edited by - afterburn on March 22, 2004 1:16:27 PM]
Damn code smiles
[edited by - afterburn on March 22, 2004 1:17:59 PM]
As you can see this could be built in C++ or VB or any other language. so the constructs of the implementation is not relevent to what your problem is.
The problem is more related in How do I make sure they do not select certain boxes.... I know which ones are disabled but how do I go about coding the issue.
The real issue here can be solved with a 2d array.
PictureBox[][] aryPic = new PictureBox[7][7] //49 Picture Boxes
//not had to make a 2d array as of yet in C# so this might be incorrect syntax. Only used ArrayList and other collections.
You might also note that your image shows a row of 6. and a cols of 7. = 42 not 49.
if you derive your a class from the picture box you can extend so properties.
class MyPicBox: PictureBox
{
bool selectable;
public MyPicBox():base()
{
selectable = true;
}
public bool IsSelectable
{
get{
return selectable;
}
set{
selectable = value;
}
}
}
This way you can just add additional logic to the object that can also display data visually to the user. Otherwise your creating multiple objects like an array of items to hold your pictures and another to hold your "selectable" value;
Maybe you need to study the underlying principals concerning design OO. The idea is to encapsulate as much as possible.
While creating the fewest objects to handle such.
So look at your question again as you do not specify anything that is language specific...
[edited by - afterburn on March 22, 2004 1:15:35 PM]
[edited by - afterburn on March 22, 2004 1:16:27 PM]
Damn code smiles
[edited by - afterburn on March 22, 2004 1:17:59 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement