Why does my timer stop?

P

Preschool Mike

I have a game where students are matching 10 shapes and must do so in a
limited amount of time. The way the game works is the student clicks on a
shape (e.g., star) and then they click on its match (e.g., another star).
Upon clicking on the second star the first star moves to the second. I’m
having two problems.
Problem 1: If the starBox (e.g., where the shape will move to) is clicked on
before the star (e.g., the shape that will be moved) my timer stops. If it’s
done correctly there are no problems. The timer will continue to work. The
timer problem is my biggest concern.
Problem 2: The first run my code that moves the shapes works correctly
(e.g., click on the star and then the starBox moves the star to the starBox),
however upon any run thereafter the player does not have to click on the star
to move it they only need to click on the starBox. If I close and then
reopen my project my code works correctly again until any run thereafter.
Here is a small sample of my code.
Option Explicit
Public StopNow As Boolean
Dim GameTime As Integer
Dim Count As Integer
Dim MyStar As Shape
Dim Count As Integer

Sub MoveStar(myStarShape As Shape)
Set MyStar = myStarShape
End Sub
Sub MoveStarTo(myStarAnswer As Shape)
MyStar.Top = myStarAnswer.Top + 1
MyStar.Left = myStarAnswer.Left + 1
If MyStar.Name = "star" And myStarAnswer.Name = "starBox" Then
CountAnswers ‘There are 10 shapes in my game.
End If
End Sub
Sub GetStarted()
GameTime = InputBox("Set the game time")
Initialize
ActivePresentation.SlideShowWindow.View.Next
CountDown
End Sub
Sub Wait(waitTime As Long)
Dim start As Double
start = Timer
While Timer < start + waitTime

If StopNow Then
Exit Sub
Else
DoEvents
End If
Wend
End Sub

Sub CountDown()

Dim X As Long
StopNow = False

For X = GameTime To 0 Step -1
If Not StopNow Then

ActivePresentation.Slides(2).Shapes("BoxTime").TextFrame.TextRange.Text =
CStr(X)
SlideShowWindows(1).View.GotoSlide
(SlideShowWindows(1).View.Slide.SlideIndex)
Wait (1)
End If
Next

If Not StopNow Then
MsgBox ("You're out of time!")
End If
End Sub

Sub DidIWin()
If Count = 10 Then ‘There are 10 shapes in my game. If count = 10 then
the clock stops and they get winning message, else the timer continues.
StopNow = True
ActivePresentation.Slides(2).Shapes("BoxTime").TextFrame.TextRange.Text =
"You Win!"
Else
StopNow = False
End If
End Sub

Sub CountAnswers()
Count = Count + 1
End Sub

Sub Initialize()
MoveShapesHome
Count = 0
End Sub
 

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

Top