What am I doing wrong with this 'Concentration' game?!

D

David N

I've been trying to get this working, but I am obviously
doing something basically wrong.
I am trying to build a template for a 'Memory' game to use
with students, based on the TV show 'Concentration'. The
main screen has 36 action buttons in a grid, with a rebus
puzzle behind them. Contestants choose first one button,
then a second one which they think is the matching picture
to the first. If they are correct, 'Match!!!' is
displayed, and the grid redisplays, but with the two
matching action buttons invisible, thus revealing part of
the underlying puzzle. If they are incorrect, the grid
redisplays, ready for the next contestant.
I've set up 38 slides. #s 1-36 are the picture pairs.
Under each picture is a button ('Done') with the action
set to run Sub 'Done'. #37 is the grid of action buttons.
Each action button has text being a number from 1-36, is
named with its number, and is set to run
Sub 'ButtonClick'. #38 Has text that says 'Match!!!', and
a button that is set to run Sub 'AfterMatch'.
Running the show, when I click a button, nothing happens.
(I want it to display the slide with the same number as
the button).
I would like to continue work on this to somehow keep
score of the contestant's matches, but there's no point of
even trying, since I can't get the basic show to work
correctly.

Here is my code:
Public vChoiceNumber As Integer
Public vButton1 As Integer
Public vButton2 As Integer
Public vPicName1 As String
Public vPicName2 As String
Public GoToSlideNumber As Integer
Sub Intialize()
ActivePresentation.SlideShowWindow.View.GotoSlide (38)
vPicName1 = ""
vPicName2 = ""
vButton1 = ""
vButton2 = ""
GoToSlideNumber = ""
vChoiceNumber = ""
End Sub

Sub ButtonClick(oShape As Shape)

If ChoiceNumber = "" Then
vButton1 = oShape.Name
ChoiceNumber = "1"
ActivePresentation.Slides(38).Shapes(puzzle).Visible =
False 'to prevent puzzle from showing during screen redraw
on return to slide
GoToSlideNumber = vButton1
ActivePresentation.SlideShowWindow.View.GotoSlide
(GoToSlideNumber)
vPicName1 =
ActivePresentation.SlideShowWindow.View.Slide.Shapes
(2).Name
ElseIf ChoiceNumber = "1" Then
vButton2 = oShape.Name
ChoiceNumber = "2"
ActivePresentation.Slides(38).Shapes(puzzle).Visible =
False
GoToSlideNumber = vButton2
ActivePresentation.SlideShowWindow.View.GotoSlide
(GoToSlideNumber)
vPicName2 =
ActivePresentation.SlideShowWindow.View.Slide.Shapes
(2).Name
End If

End Sub

Sub Done()
'
' Macro created 5/31/04 by DocuMed
'
If ChoiceNumber = "1" Then
ActivePresentation.SlideShowWindow.View.GotoSlide (38)
ActivePresentation.Slides(38).Shapes(puzzle).Visible =
True
ElseIf ChoiceNumber = "2" Then
If vPicName1 = vPicName2 Then
ActivePresentation.SlideShowWindow.View.GotoSlide
(39)
ElseIf vButton1 <> vButton2 Then
ActivePresentation.SlideShowWindow.View.GotoSlide
(38)
ActivePresentation.Slides(38).Shapes
(puzzle).Visible = True
End If
ChoiceNumber = ""
End If

End Sub
Sub AfterMatch()
ActivePresentation.Slides(38).Shapes
(vButton1).Visible = False
ActivePresentation.Slides(38).Shapes
(vButton2).Visible = False
ActivePresentation.Slides(38).Shapes
(puzzle).Visible = True
vPicName1 = ""
vPicName2 = ""
vButton1 = ""
vButton2 = ""
End Sub
Sub NameShape() 'This is for setup, to name shapes

Dim Name$
On Error GoTo AbortNameShape
If ActiveWindow.Selection.ShapeRange.Count = 0 Then
MsgBox "No Shapes Selected"
Exit Sub
End If
Name$ = ActiveWindow.Selection.ShapeRange(1).Name
Name$ = InputBox$("Give this shape a name", "Shape Name",
Name$)
If Name$ <> "" Then
ActiveWindow.Selection.ShapeRange(1).Name = Name$
End If
Exit Sub

AbortNameShape:
MsgBox Err.Description

End Sub
 
D

dee

wow! I teach math and don't have a clue of how to do what you are asking
but if you get it working, would you be willing to share the template? I
would love to be able to do something like this with--solve an equation and
match it with the correct answer. Since you are doing all the work, I know
this is a lot to ask, but I wouldn't begin to know how to do this--so if you
could think about it?
dee
 
B

Bill Foley

I haven't tried this before, but the first question is - "Are you
controlling the game?" If so, you can simply use buttons that run macros
that either hide the images showing the puzzle at the back or replace them.
You click on a button number and the button hides. You click on another
button and it hides. This shows two images behind them. If they match,
click the "Match" button and those buttons also hide. If they don't match,
replace the two buttons you clicked to show the images, leaving all buttons
back the way it was.

If you are trying to set this up to run automatically, all you will need to
do is to use something like a Select Case to see if two similar buttons were
clicked to hide the various images. I would think that with a picture set
as the background of your slide, one set of duplicated images set on top of
the background, then another set of buttons (with code set behind them) that
hide to show the images, you can do this whole thing on one slide.

I doubt I will get time today to work on something, but should in the next
day or two. If I do, I will post it up on my website.

--
Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
"Success, something you measure when you are through succeeding."
 
G

Guest

I agree with Bill that you can probably do this just as easily on one slide. Making 38 slides seems to complicate things, but that is not your error. If I understand what you are doing, I think you have 36 shapes on your slides that you have named. You have given pairs of shapes the same name so when someone clicks on two shapes, you check to see if they have the same name. This might not be your whole problem, but it is not a good idea to give two shapes on the same slide the same name. As an alternative, I suggest that you don't worry about the shape names at all. Instead, put text in each of the slides and check to see if the text is the same. Something like:

If myShape1.TextFrame.TextRange.Text = myShape2.TextFrame.TextRange.Text Then

Now, you can make the text invisible by giving it the same color as the background color of the shape.

Once you get this part working, keeping score should be a piece of cake. I wish I had more time to look at this in more detail to find out if there are other problems. This looks like a great project.

--David

David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
S

Shyam Pillai

I'll try to post a complete example later in the day. It is a lot easier
doing it with a single slide.
 
D

David N

Hi David,
Thanks for your reply. I actually have spent a lot of time
studying your samples, and I greatly appreciate your
sharing them.
I can't imagine how to do this on one slide. There is only
one picture per slide. I have 36 slides, with 18 pairs of
pictures. I can try the text idea, which seems more
foolproof. But I can't get the slides to show on the
button click!
-----Original Message-----
I agree with Bill that you can probably do this just as
easily on one slide. Making 38 slides seems to complicate
things, but that is not your error. If I understand what
you are doing, I think you have 36 shapes on your slides
that you have named. You have given pairs of shapes the
same name so when someone clicks on two shapes, you check
to see if they have the same name. This might not be your
whole problem, but it is not a good idea to give two
shapes on the same slide the same name. As an
alternative, I suggest that you don't worry about the
shape names at all. Instead, put text in each of the
slides and check to see if the text is the same.
Something like:
If myShape1.TextFrame.TextRange.Text =
myShape2.TextFrame.TextRange.Text Then
Now, you can make the text invisible by giving it the
same color as the background color of the shape.
Once you get this part working, keeping score should be a
piece of cake. I wish I had more time to look at this in
more detail to find out if there are other problems. This
looks like a great project.
 
D

David N

Thank you, Bill.
I already run this with the keyboard, but I'm intent on
trying to automate it because:
The show is presented in a dark auditorium for 50 or more
kids at a time in teams of ten, and they get very into it.
Manual control is prone to (even in the light!) errors
which upset the contestants, and puts pressure on the
operator. It is also slower.
 
D

David M. Marcovitz

Thanks. I thought some of your coding style looked familiar (like you
had learned something from my examples). I'm glad you find my site
useful. If you get this to work, maybe you can send it to me, and I can
put it up on my site under my "Examples from Real People" section.

As far as doing this on one slide, I'm picturing layers of pictures. If
I understand what you want to do correctly, you need one big picture at
the bottom. Then you need two layers of 36 pictures on top of that.
When someone clicks on a box, that box gets hidden to reveal the box
below it (with some sort of symbol on it). When they click on another
box, that box gets hidden as well. If the symbols match, the boxes with
symbols are hidden to reveal a piece of the larger picture. If the two
symbols do not match, the top layer boxes are made visible again. I'm
not sure what purpose all the other slides serve unless your showing the
symbols as full screen pictures.

I see that Shyam has contributed to this. He is one of the real coding
experts in this group. I'll have to see if he has solved all your
problems.

--David

--
David M. Marcovitz, Ph.D.
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top