Reaction time game

How do you get it to wait a random amount of tim before saying go?

Page 1 of 1

4 Replies - 2617 Views - Last Post: 02 January 2009 - 02:55 PM Rate Topic: -----

#1 0FreakFire0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 02-January 09

Reaction time game

Posted 02 January 2009 - 12:28 PM

I am making a reaction time game, where you press a button, it waits for a random amount of time, a "GO!" label turns visible, and the player has to click as soon as they can after it says go. Then it tells the player their reaction time. My problem is that i can't get it to wait for a random amount of time. This is what i have so far:
Public Class Form1
	Dim one As Integer
	Dim two As Integer
	Dim three As Integer
	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		one = one + 1
	End Sub
	Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
		three = three + 1
	End Sub
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Timer2.Enabled = True
		Timer3.Enabled = True
		two = Rnd()
		If two < three Then
			Timer1.Enabled = True
			Label1.Visible = True
		End If
	End Sub

   
End Class

Please help me figure out how to make it wait for a random amount of time.
Thank You.

Is This A Good Question/Topic? 0
  • +

Replies To: Reaction time game

#2 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Reaction time game

Posted 02 January 2009 - 12:38 PM

This is VB.NET code, not VB (you should post VB.NET questions here).

The solution is using the Thread.Sleep() method to delay a specific action. The argument for this method is the value in milliseconds of the delay you want to set.

Make sure you add a reference to System.Threading before using Thread.Sleep().
Was This Post Helpful? 1
  • +
  • -

#3 0FreakFire0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 02-January 09

Re: Reaction time game

Posted 02 January 2009 - 12:44 PM

I am making a reaction time game, where you press a button, it waits for a random amount of time, a "GO!" label turns visible, and the player has to click as soon as they can after it says go. Then it tells the player their reaction time. My problem is that i can't get it to wait for a random amount of time. This is what i have so far:
Public Class Form1
	Dim one As Integer
	Dim two As Integer
	Dim three As Integer
	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		one = one + 1
	End Sub
	Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
		three = three + 1
	End Sub
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Timer2.Enabled = True
		Timer3.Enabled = True
		two = Rnd()
		If two < three Then
			Timer1.Enabled = True
			Label1.Visible = True
		End If
	End Sub

   
End Class

Please help me figure out how to make it wait for a random amount of time.
Thank You.
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Reaction time game

Posted 02 January 2009 - 01:18 PM

Please don't create duplicate topics. Topics merged :)
Was This Post Helpful? 0
  • +
  • -

#5 HikariMisako  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 12
  • Joined: 18-December 08

Re: Reaction time game

Posted 02 January 2009 - 02:55 PM

how about a random int that is the time of a timer?

dim Time as integer
Randomize()
Time = int(rnd * 100) + 1  
Time = Time * 1000   'makes it seconds
tmrWait.interval = Time

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1