Jump to content

MasterMind

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
15 replies to this topic

#1
wazofski

wazofski

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
I need some help with the game I'm making: Mastermind, I think everybody knows the game.

Problem:

I got a few panels with colors and a 4 white boxes. If you press a panel lets say with the color Red then the first white box will turn Red, but if the first box already has a color then the next box will turn red if that is white. I tried a lot of things but none worked.

And I'm using vb 2005 express edition

Help pls and thx in advance

Edited by wazofski, 10 May 2008 - 10:00 AM.


#2
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Use an If statement, as in:
If pnlMyPanel.BackColor <> Color.White Then
'Color is already set, try another one.
End If
See?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#3
wazofski

wazofski

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
I already tried that but that didnt really worked because after a few of those If statements for all panels then if you click the colorpanel it will color all white boxes.

#4
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
How about this:
Select Case Color.White

 Case pnlOne.BackColor
   'Set color for pnlOne.
 End Case

Case pnlTwo.BackColor
   'Set color for pnlTwo.
 End Case

Case pnlThree.BackColor
   'Set color for pnlThree.
 End Case

Case pnlFour.BackColor
   'Set color for pnlFour.
 End Case

End Select

Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#5
wazofski

wazofski

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
Thank you very much, it works :)

#6
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Great! Don't forget to add +rep to my post.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#7
wazofski

wazofski

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
Other problem:

At the top of my form I got 4 boxes that will random have some colors, Below those boxes I have some boxes that will turn in the color you click on the panels. Next to these boxes I have some little boxes who can switch to 2 colors: Red and White.
Red = A color is in the right place
White = The color stands in the code you need to crack but not on the right place

If you have a color on the right place then a little box will turn red. If you dont have it on the right place but the color is in the code you need to crack it will turn white. And in any other case it stays gray. How can I do this?

#8
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
I'm not sure about what you mean by 'color on the right place', but here's the sort of structure (excluding the code for the right-place bit)
If [I](color is in right place)[/I] Then
pnlThePanel.BackColor = Color.Red
ElseIf [I](color is in the wrong place)[/I] Then
pnlThePanel.BackColor = Color.White
Else
pnlThePanel.BackColor = Color.Gray

See the gist of it?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#9
wazofski

wazofski

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
Hmm yeah but I think its not that easy, because I have 4 colors you need to gues. So there are a lot of combinations.

#10
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Sorry, I don't quite understand. Could you explain exactly what you want to?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#11
wazofski

wazofski

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
I think I already have it :) Thx for help, if it doesn't work I will tell you with some screenshots with it

#12
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Sure thing. :)
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums