Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Spinning Roulette Wheel

Spinning Roulette Wheel

Scheduled Pinned Locked Moved C#
csharpwpfwinformsquestion
19 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P PIEBALDconsult

    Not entirely on-topic, but... I can't stand games that waste time doing crap like that. Just randomize the number already! I'll always remember that the Amstrad that my father bought (mid-80s) had a Wheel Of Fortune game installed, but the clock was much slower than the developers had intended -- waiting for the wheel to stop spinning was horrible. What I recommend is randomizing a number and displaying just that number. Do it a few (10?) times so the user sees the numbers flashing. That's what I do for a dice game I wrote; it's much quicker and easier.

    S Offline
    S Offline
    stephen darling
    wrote on last edited by
    #8

    PIEBALDconsult wrote:

    I can't stand games that waste time doing crap like that.

    Maybee. I do see where your comming from, but the idea is to design a realistic and working mini roulette game, so the spinning wheel is a real big part of it. Also, this is just a fun app, and a doubt many other people will use it. The main idea for this is a learning curve for a beginner, and not so much the spinning wheel, but the fact that I can learn how to spin the wheel realisticaly, which may be usefull for other stuff. but thank you for your point of view! Steve

    1 Reply Last reply
    0
    • R Rob Philpott

      Yes, WPF makes things like that considerably easier. No concern though. First thing to do is rotate the image, which is presumably represented as a bitmap in code. Get to the graphics object, and that's got two methods TranslateTransform and RotateTransform (as I recall) which should do the rotation. If everything's perfectly circular you may not need the translate transform. Then, create a method which rotates the image as needed. I'd probably create a custom control for just this purpose. You'll have to use the System.Windows.Forms timer to update the angle in such a way to make it look like real movement.

      Regards, Rob Philpott.

      S Offline
      S Offline
      stephen darling
      wrote on last edited by
      #9

      Rob Philpott wrote:

      Yes, WPF makes things like that considerably easier.

      I am excited to get started with WPF, however, I think I should get through my "Head First C#" Book first, and learn C# properly. I will look into what you have sugested, and see if I can get something going. Thank you for the sugestion, Regards, Stephen

      1 Reply Last reply
      0
      • P PIEBALDconsult

        38 in the U.S. -- 00 .

        M Offline
        M Offline
        Marcus_2
        wrote on last edited by
        #10

        PIEBALDconsult wrote:

        38 in the U.S. -- 00 .

        0 for the casino. 00 for the government? :confused: ;)

        P 1 Reply Last reply
        0
        • S stephen darling

          Hi, I was just woundering if anyone knows how I would do this... I have an image of a roulette wheel, and I would like to animate it as it was spinning, faster to slower and then stop. How would I achive this using c# and winforms, as I am not ready to delve into WPF just yet? Thank you, Kind Regards, Steve

          S Offline
          S Offline
          SledgeHammer01
          wrote on last edited by
          #11

          You should just bite the bullet and learn WPF. Doing this in, well, GDI/GDI+ is the correct term here since Winforms has nothing to do with your question, will require you to worry about such silly things as multi-threading, timers, double buffering, geometry, etc and you'll have to write a lot of code. In WPF, you just attach an animation that animates the rotation angle from 0 to 360 degrees and you're done. 5 minute job max. ZERO code as it can all be done with one line of XAML.

          S 1 Reply Last reply
          0
          • S SledgeHammer01

            You should just bite the bullet and learn WPF. Doing this in, well, GDI/GDI+ is the correct term here since Winforms has nothing to do with your question, will require you to worry about such silly things as multi-threading, timers, double buffering, geometry, etc and you'll have to write a lot of code. In WPF, you just attach an animation that animates the rotation angle from 0 to 360 degrees and you're done. 5 minute job max. ZERO code as it can all be done with one line of XAML.

            S Offline
            S Offline
            stephen darling
            wrote on last edited by
            #12

            SledgeHammer01 wrote:

            You should just bite the bullet and learn WPF.

            What? While learning C#?

            SledgeHammer01 wrote:

            one line of XAML.

            Could you show one line that does this? Either way, I am starting to lean toward the idea of WPF. Thank you, Steve

            S 1 Reply Last reply
            0
            • S stephen darling

              SledgeHammer01 wrote:

              You should just bite the bullet and learn WPF.

              What? While learning C#?

              SledgeHammer01 wrote:

              one line of XAML.

              Could you show one line that does this? Either way, I am starting to lean toward the idea of WPF. Thank you, Steve

              S Offline
              S Offline
              SledgeHammer01
              wrote on last edited by
              #13

              See DoubleAnimation http://msdn.microsoft.com/en-us/library/system.windows.media.animation.doubleanimation.aspx[^]. Ok, its a little more then one line :), but here is an easy example of animating the rotation transform http://www.galasoft.ch/mydotnet/articles/article-2006102701.aspx[^]

              S 1 Reply Last reply
              0
              • M Marcus_2

                PIEBALDconsult wrote:

                38 in the U.S. -- 00 .

                0 for the casino. 00 for the government? :confused: ;)

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #14

                Heck no, the guv'mint takes more than that.

                1 Reply Last reply
                0
                • S SledgeHammer01

                  See DoubleAnimation http://msdn.microsoft.com/en-us/library/system.windows.media.animation.doubleanimation.aspx[^]. Ok, its a little more then one line :), but here is an easy example of animating the rotation transform http://www.galasoft.ch/mydotnet/articles/article-2006102701.aspx[^]

                  S Offline
                  S Offline
                  stephen darling
                  wrote on last edited by
                  #15

                  Thank you, That has gave me something to look over the weekend. Regards, Stephen

                  1 Reply Last reply
                  0
                  • S stephen darling

                    Hi, I was just woundering if anyone knows how I would do this... I have an image of a roulette wheel, and I would like to animate it as it was spinning, faster to slower and then stop. How would I achive this using c# and winforms, as I am not ready to delve into WPF just yet? Thank you, Kind Regards, Steve

                    A Offline
                    A Offline
                    Alan Balkany
                    wrote on last edited by
                    #16

                    For a more realistic spinning roulette wheel (even on a slow system) use blurred intermediate images. These will give an appearance more like what a person would actually perceive seeing a real wheel spinning. Transition to actual images as the wheel slows down.

                    S 1 Reply Last reply
                    0
                    • A Alan Balkany

                      For a more realistic spinning roulette wheel (even on a slow system) use blurred intermediate images. These will give an appearance more like what a person would actually perceive seeing a real wheel spinning. Transition to actual images as the wheel slows down.

                      S Offline
                      S Offline
                      stephen darling
                      wrote on last edited by
                      #17

                      Alan Balkany wrote:

                      For a more realistic spinning roulette wheel (even on a slow system) use blurred intermediate images. These will give an appearance more like what a person would actually perceive seeing a real wheel spinning. Transition to actual images as the wheel slows down.

                      This sounds like a very interesting idea, however, I would not have a clue where to start by doing this. Would you possibly be able to provide a little more information please? Thank you, Regards, Stephen

                      A 1 Reply Last reply
                      0
                      • S stephen darling

                        Alan Balkany wrote:

                        For a more realistic spinning roulette wheel (even on a slow system) use blurred intermediate images. These will give an appearance more like what a person would actually perceive seeing a real wheel spinning. Transition to actual images as the wheel slows down.

                        This sounds like a very interesting idea, however, I would not have a clue where to start by doing this. Would you possibly be able to provide a little more information please? Thank you, Regards, Stephen

                        A Offline
                        A Offline
                        Alan Balkany
                        wrote on last edited by
                        #18

                        This http://www.blackpawn.com/texts/blur/default.html[^] gives basic blurring algorithms, but they're rectangle-oriented, and you need to adapt them for rotation. So, instead of averaging in a rectangular region for each pixel, you'd use an arc representing a fraction of the roulette wheel's rotation, at the pixel's distance from the center +/- a delta constant.

                        S 1 Reply Last reply
                        0
                        • A Alan Balkany

                          This http://www.blackpawn.com/texts/blur/default.html[^] gives basic blurring algorithms, but they're rectangle-oriented, and you need to adapt them for rotation. So, instead of averaging in a rectangular region for each pixel, you'd use an arc representing a fraction of the roulette wheel's rotation, at the pixel's distance from the center +/- a delta constant.

                          S Offline
                          S Offline
                          stephen darling
                          wrote on last edited by
                          #19

                          Thank you, I will look into this. Regards, Stephen

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups