Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

Just wondering what would be the best way about making a reel spin in vb.net? I am trying to create a poker machine and would like to give the effect the reels are spinning around when you press spin.

I have setup 5 Buttons in a panel. with the different pictures on them, I though maybe you could you a timer to make them move down and soon as it gets to a set location move back to the top but it takes up to much cpu power and not a smooth spin.

Any idea guys?

What I have tried:

This is what I tried but makes the computer lag to much:

VB
For i As Integer = 0 To Me.Button1.Height
            If Button3.Location.Y = 500 Then
                Button3.Location = New Point(0, -100)


            Else

                Me.Button3.Top += 100
            End If
            Application.DoEvents()

            If Button2.Location.Y = 500 Then
                Button2.Location = New Point(0, -100)


            Else

                Me.Button2.Top += 100
            End If
            Application.DoEvents()

            If Button1.Location.Y = 500 Then
                Button1.Location = New Point(0, -100)

            Else

                Me.Button1.Top += 100
            End If
            Application.DoEvents()

            If Button4.Location.Y = 500 Then
                My.Settings.Reel2 = My.Settings.Reel2 + 1
                Button4.Location = New Point(0, -100)
            Else
                Me.Button4.Top += 100
            End If
            Application.DoEvents()

            If Button5.Location.Y = 500 Then
                Button5.Location = New Point(0, -100)


            Else

                Me.Button5.Top += 100
            End If
            Application.DoEvents()

            If Button6.Location.Y = 500 Then
                Button6.Location = New Point(0, -100)


            Else

                Me.Button6.Top += 100
            End If

            Application.DoEvents()

            If Button7.Location.Y = 500 Then
                Button7.Location = New Point(0, -100)
            Else
                Me.Button7.Top += 100
            End If
            Application.DoEvents()

            If Button8.Location.Y = 500 Then
                Button8.Location = New Point(0, -100)
            Else
                Me.Button8.Top += 100
            End If
            Application.DoEvents()

            If Button9.Location.Y = 500 Then
                Button9.Location = New Point(0, -100)
            Else
                Me.Button9.Top += 100
            End If



            Dim d1 As Date = Date.Now
            While Date.Now.Subtract(d1).TotalMilliseconds < 7
                Application.DoEvents()
            End While
        Next
Posted
Updated 2-Aug-19 10:14am

The reels don't "spin". You put up blurred graphic images of wheels that have images flying by (think long camera exposure) to give the illusion of spinning wheels.

Those images in car magazines where you see a car that looks like it's really moving fast down the road, is actually the car doing about 5 mph and the shutter on the camera being held open for about a couple seconds, depending on lighting.
 
Share this answer
 
Movies run at 24 FPS (frames per second)

High end VR (virtual reality) runs at 90 FPS; below that, it can make you sick.

So, if you're going to "spin", use a spin rate in that range if you're "flashing" images.

So, think of a "timer" with an event interval of around 24 FPS; which is not cpu intensive. And the form will respond to button clicks to stop spins.

.net - Constantly Update Current Time Display On A Windows Form? - Stack Overflow[^]
 
Share this answer
 
v2
See video tutorial here: Visual Basic 2015 - Einarmiger Bandit / Slot Machine [HowTo #044] - YouTube[^]
Another option might be using the BitBlt function to copy the image from a larger image, see example here: Copying graphics with BitBlt (.NET Style)[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900