|
-
July 11th, 2006, 07:42 AM
#4
Re: Create a wheel for a game
Wow....did the above and it works great. Heres my code.....hopefully it'll help someone:
Code:
Private Sub SpinWheelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SpinWheelButton.Click
spin the wheel
Call SpinWheel()
End Sub
Private Sub SpinWheel()
' This will spin the wheel in what will look like a random pattern
SpinWheelButton.Enabled = False
TimerForWheel.Interval = 1
TimerForWheel.Enabled = True
End Sub
Private Sub TimerForWheel_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerForWheel.Tick
NumberForWheel += 1
WheelTickSound.Play()
TimerForWheel.Interval = CInt(TimerForWheel.Interval + Int((Rnd() * 10) + 10))
If NumberForWheel >= 20 Then NumberForWheel = 0
If TimerForWheel.Interval >= 400 Then
TimerForWheel.Enabled = False
SpinWheelButton.Enabled = True
End If
WheelLabel.Text = NumberForWheel.ToString
End Sub
So there is a button, a timer, and in the above example just a label to see the number although you could put a picture box (which I will have) and assign images based on the number. When you click the button to spin the wheel it starts the timer with a small interval. As the timer runs it adds to the interval until its a little under half a second (you can play with this and the random interval add). So it acts like a wheel that gets slower and slower. Needs a little tweaking of the random but otherwise its working well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|