|
-
July 7th, 2006, 01:58 PM
#1
Create a wheel for a game
I don't even know where to start with this. I'm looking to make a spinable wheel, like the game of Life has, but in VB.Net 05. I could wuss out and do the dice thing with a random number and some images but I was hoping to be a little more clever. Problem is I can't find anything remotely close. I just want a example of a small circle that you click a button to spin and it lands on a number (1 - 10) and you can poll the number so you can move spaces or select something ect. Anyone have any ideas of where to start? I've searched but haven't found anything.
-Allan.
-
July 8th, 2006, 02:19 PM
#2
Re: Create a wheel for a game
Ive seen some example of this somewhere but i dont remember where. but try researching this point.
-Friction, i think some bloke called euler has an equation.
basically randomize the starting velocity of the cirlce and randomize the amount of friction when the button is pressed and rotate the circle acording to the velocity coughed out by the friction equation.
Obviously you would have to whack this code in a timer to constantly update the velocity.
Rich
Visual Studio 2010 Professional | Windows 7 (x64)
Ubuntu
-
July 9th, 2006, 10:00 AM
#3
Re: Create a wheel for a game
I finally found a example in VB6. Unfortunately I switched to VB 03 about 3 years ago and never looked back. So I put the code through a upgrade to 05 which left a unmanageable mess of errors. If I have a working example I can usually figure out what the author was doing and how but with so many errors I'm just pulling my hair.
I'm probably going to give up on the dynamicly created wheel and just make 20 some images of a wheel showing it landing on each number and also between each number. I'll have a timer that when called will increment a number between 0 and 19 (reseting back to 0 after 19) and will display one of the 20 images for each number (0 = show it on 1, 1 = between 1 and 2, 2 = show on two 2, etc) in order, with the interval very short at first and with each click of the timer add to the interval until its up to 3/4 to 1 second apart at which time the timer will stop. Since the images are in order and since I have the number that increments over and over I'll know where the wheel will be when the timer stops and be able to move that many spaces. Plus I can throw in a sound clip of the wheel "ticking" also called with each timer call which will make it seem like a real wheel.
Its probably not the best way to do it but the code sounds relatively easy to do this way. This make sense?
-Allan.
-
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.
-
December 27th, 2025, 08:49 AM
#5
Re: Create a wheel for a game
 Originally Posted by CrystalAnnoysMe
I don't even know where to start with this. I'm looking to make a spinable wheel, like the game of Life has, but in VB.Net 05. I could wuss out and do the dice thing with a random number and some images but I was hoping to be a little more clever. Problem is I can't find anything remotely close. I just want a example of a small circle that you click a button to spin and it lands on a number (1 - 10) and you can poll the number so you can move spaces or select something ect. Anyone have any ideas of where to start? I've searched but haven't found anything.
-Allan.
separate logic from visuals. Use a random number (1?10) to decide the result, then animate a circle (rotate an image or draw with GDI+) so it looks like it?s spinning before stopping on that number. In VB.NET 2005, a Timer + rotation angle works well, and you just slow the timer down to simulate friction. If you want inspiration for how wheels map numbers to segments and stops, tools like ruleta virtual online show the basic idea clearly
Last edited by 2kaud; December 28th, 2025 at 04:39 AM.
Reason: Web link removed
-
December 27th, 2025, 08:52 AM
#6
Re: Create a wheel for a game
start is to separate logic from visuals. Use a random number (1?10) to decide the result, then animate a circle (rotate an image or draw with GDI+) so it looks like it?s spinning before stopping on that number. In VB.NET 2005, a Timer + rotation angle works well, and you just slow the timer down to simulate friction. If you want inspiration for how wheels map numbers to segments and stops, tools like ruleta aleatoria show the basic idea clearly
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
|