[vb 2005] Simon Says
[vb 2005] Simon Says
[vb 2005] Simon Says
[vb 2005] Simon Says
[vb 2005] Simon Says
[vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says
[vb 2005] Simon Says [vb 2005] Simon Says
[vb 2005] Simon Says
Go Back  Xtreme Visual Basic Talk > > > [vb 2005] Simon Says


Reply
 
Thread Tools Display Modes
  #1  
Old 07-10-2010, 11:00 AM
Amerigo's Avatar
Amerigo Amerigo is offline
Centurion
 
Join Date: Jan 2009
Location: USA
Posts: 175
Question [vb 2005] Simon Says


I didn't think this would be so difficult. I am having trouble juggling arrays/variables/integers and timer events.
At this point, my main concern is getting the randomly selected button to blink. With either method below, the button dims and the application hangs up in the loop. Isn't there a simple "Wait" function?
Code:
 Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
        n = 1
        Timer1.Enabled = True
        Timer1.Start()
        run()

    End Sub

    Private Sub run()
        Dim count As New Stopwatch


        For i = 1 To n

            num = r.Next(1, 4)

            If num = 1 Then
                b1.Lit = False
                count.Start()
                '
                'While count.ElapsedMilliseconds < 500
                Do Until Now() + TimeSerial(0, 0, 1)



                Loop

                'End While
                b1.Lit = True
                count.Reset()
            End If


            If num = 2 Then
                b2.Lit = False
                count.Start()

                While count.ElapsedMilliseconds < 500
                    Do

                    Loop
                End While
                b2.Lit = True
                count.Reset()
            End If


            If num = 3 Then
                b3.Lit = False
                count.Start()

                While count.ElapsedMilliseconds < 500
                    Do

                    Loop
                End While
                b3.Lit = True
                count.Reset()
            End If

' This one works (so far).
            If num = 4 Then
                b4.Lit = False
                count.Start()

                While count.ElapsedMilliseconds < 500
                    If count.ElapsedMilliseconds = 500 Then
                        Exit While
                    End If
                End While
                b4.Lit = True
                count.Reset()
            End If
        Next
        n = n + 1

    End Sub
Now comes the complex part of hard part of getting the computer to remember the sequence and then comparing that to what the player does...

I think I got the blink part resolved. I still need help with the 'memory' part. I don't know if the variable 'Memory' needs to be a integer, string, boolean, or what.. I also don't know the expression/formula/algorithm needed.
I imagine it's going to be even trickier to 'remember' the player's button clicks.
I hope to be able to compare "Memory" to "PlayerClicks" with something as simple as:
Code:
if Memory <> PlayerClicks then
msgbox ("Game over"), msgboxstyle.YesNo, "Play again?")
bla bla bla
end if
__________________
Amerigo

Last edited by Amerigo; 07-10-2010 at 11:38 AM. Reason: Partial fix
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
[vb 2005] Simon Says
[vb 2005] Simon Says
[vb 2005] Simon Says [vb 2005] Simon Says
[vb 2005] Simon Says
[vb 2005] Simon Says
[vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says [vb 2005] Simon Says
[vb 2005] Simon Says
[vb 2005] Simon Says
 
[vb 2005] Simon Says
[vb 2005] Simon Says
 
-->