Vanilla Javascript - Wheel Of Fortune mini game

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024
  • #javascript #css #programming #code
    Part 2 here, new for 2021! : • Vanilla Javascript - W...
    In this video I show how to create a rotating wheel of fortune with a little JS and CSS. Less is more!
    Code:
    github.com/wei...
    Support me by subscribing to this channel ❤️
    Do you want to master #react, #gatsby, or #svelte fast? ⏩ 🚀 👩‍🚀
    Check out my premium courses at www.weibenfalk...
    -
    Find me somewhere below:
    Linkedin: / thomas-weibenfalk-7635...
    Twitter: / weibenfalk
    Github: github.com/wei...
    FreeCodeCamp: www.freecodeca...
    Dev.to: dev.to/weibenfalk

ความคิดเห็น • 80

  • @supa1009
    @supa1009 3 ปีที่แล้ว +5

    you are a great teacher, your enthusiasm makes the tutorial interesting! awesome job

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว

      Thanks! Highly appreciate that comment.

  • @nathanellis7819
    @nathanellis7819 3 ปีที่แล้ว +1

    Loved it! Please more typescript! please please

  • @goswamianshuman
    @goswamianshuman 2 ปีที่แล้ว

    you did explained it in a well known manner, this is one of the best content on youtube thankyou so much for providing this content to the community!!

  • @CodingJourney
    @CodingJourney 4 ปีที่แล้ว +1

    Beautiful!! Thank you 🙂

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      Coding Journey thank you for your support!

    • @wgrudolf9711
      @wgrudolf9711 4 ปีที่แล้ว

      @@Weibenfalk I really interested. Can you teach me the code for show the result of spin wheel? Let say the result in text box. I will add the code. Thank you for your kind, sir. :)

  • @nicklansbury3166
    @nicklansbury3166 4 ปีที่แล้ว +1

    In the UK we call it a ladybird. Cool project!

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      Aha! Thank you! Great to know =)

  • @sol3cito33
    @sol3cito33 3 ปีที่แล้ว +3

    Could you make a tutorial that is related to this one, explaining how to read the outcome on the wheel? The wheel is an image, with different "outcomes" such as the frog, the snowman, the koala etc. How to code a function that captures the outcome (once the wheel stopped spinning)? Let's say, the koala pays SEK 500,000. But how can we tell JavaScript that the wheel stopped at the koala?

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว +3

      Hey and thanks. You can calculate this by the amount of degrees the wheel Han spun. When it stops you know the degrees and each section on the wheel is a certain amount of degrees.

    • @sol3cito33
      @sol3cito33 3 ปีที่แล้ว

      @@Weibenfalk Tackar! Jag skall försöka det! :-)

  • @codeswithankit4316
    @codeswithankit4316 4 ปีที่แล้ว +1

    I will add this in my today's project

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      Wonderful .. thank you! =)

  • @hieutancodeproject
    @hieutancodeproject 4 ปีที่แล้ว +1

    Thanks a lot

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว +1

      Thanks for your support.

    • @si4965
      @si4965 4 ปีที่แล้ว

      đi lạc gặp idol , e đang tìm làm vòng quay -:D

  • @thefavourdArt1850
    @thefavourdArt1850 3 ปีที่แล้ว +1

    Hey great video🙌💥.....can you make us another video on how to display the results (icons) on where the pointer stops?..
    I've struggled to make one

  • @cv3787
    @cv3787 4 ปีที่แล้ว

    Riktigt bra tutorial!

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      Tack. Det glädjer mig att höra! =)

  • @est_carsounds
    @est_carsounds 4 ปีที่แล้ว +3

    Nice tutorial, thanks! Instead of using the image you used, i used one of a roulette with 37 colors: 18 red, 18 black and 1 green. My question is: for example if it goes red, I will know, but the site will not, because it is just an image. how can i tell to the site what color came out?

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว +1

      Thanks! You have to use Javascript and do some calculations for that ... There's many approaches you can choose from to achieve what you want. If you know the rotation on the wheel when it stops and you also know the degrees intervals on your image where the colors appear you can calculate it from that. But it requires more work than in this video. =)

    • @est_carsounds
      @est_carsounds 4 ปีที่แล้ว +1

      @@Weibenfalk can you be a little more specific?

  • @feresepel
    @feresepel 3 ปีที่แล้ว +1

    Coolie woolie WOWIE boi its coool

  • @imhan7026
    @imhan7026 4 ปีที่แล้ว +2

    Thank you, !!

  • @floodyboy5307
    @floodyboy5307 4 ปีที่แล้ว

    Very cool 👍🏼

  • @erahmadkamram
    @erahmadkamram 4 ปีที่แล้ว +1

    Hey! that is a nice video and you have done a great job. I just want to know how to find in javascript at which icon the wheel is stopped?
    i mean suppose i have created wheel using html and and i have given a unique id to each icon. How will i find out at which position the wheel is stopped.

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว +1

      Hey, thanks. Glad you enjoyed it. It all depends on how you've structured your html/code. If you know the rotation of the div that you rotate and also know the position of all the icons you can calculate it that way. So if you're starting from 0 degrees rotation and then place the icons around the axis you know the degrees that the icons will "cover" ... Hard to explain in a comment like this but hope you understand what I'm getting it. =) Haven't tried it out myself but I think that's a way that will work.

  • @frajdst
    @frajdst 8 หลายเดือนก่อน

    thank you for this great video!!! I'm trying to improve this wheel putting an alert at the end of the transition with a random message of success. Do you think I can recall it inside the function in wheel.addeventListener(transitioned)?

  • @wgrudolf9711
    @wgrudolf9711 4 ปีที่แล้ว +1

    great code, sir. Can we pick the result & the code?

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว +2

      It requires some more code to pick the result also. In this case I did it just visually like a real “analog” wheel :)

  • @siennakei6128
    @siennakei6128 4 ปีที่แล้ว +1

    this is really cool, thanks :)
    is there a way to slow down how quickly the wheel spins?

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      Thanks! =) Yes, you can modify the CSS properties for that as the animation is made with only CSS. Play around with the values and you can see how it changes =)

    • @siennakei6128
      @siennakei6128 4 ปีที่แล้ว

      @@Weibenfalk ah yes. thanks again :)

    • @siennakei6128
      @siennakei6128 4 ปีที่แล้ว +1

      @@Weibenfalk me again :) could you please tell me if theres a way to add a pop-up for when you land on one of the segments?

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      @@siennakei6128 There's always a way to do anything. =) That would require some Javascript. There's an event listener that's called onTransitionEnd in Javascript. Would require a little bit of thinking but it should be possible with that one: developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/ontransitionend

    • @siennakei6128
      @siennakei6128 4 ปีที่แล้ว +1

      @@Weibenfalk amazing :) ty

  • @mikkaruru
    @mikkaruru 2 ปีที่แล้ว

    Hello, Thomas! Thanks for your videos! Like them all! By the way, which license is your code under (particular this one, Wheel of Fortune)? How free may anyone use it?

    • @Weibenfalk
      @Weibenfalk  2 ปีที่แล้ว +1

      Thanks .. appreciate the support! Use whatever you want of my own code ... I don't care =)

    • @mikkaruru
      @mikkaruru 2 ปีที่แล้ว

      @@Weibenfalk , thank you! 👍

    • @mikkaruru
      @mikkaruru 2 ปีที่แล้ว

      @@Weibenfalk , thank you! 👍

  • @ludmilagaetmank5898
    @ludmilagaetmank5898 4 ปีที่แล้ว +2

    You just save me!

  • @kevinlnwza4803
    @kevinlnwza4803 3 ปีที่แล้ว

    Hello, can I ask a question? I have to want to know what the result is. Thank you.

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว

      Well. This was meant to be visual. That is to display on the screen ... if you want to type out and calculate the result you would want to calculate depending on the degrees rotated and give the different values an interval between different degree angels for example

  • @sol3cito33
    @sol3cito33 3 ปีที่แล้ว

    Swedish accent for the win! :-)

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว

      Thanks! Yeah ... it's pretty cool ;)

  • @TheAlibaadshah
    @TheAlibaadshah 3 ปีที่แล้ว

    and how to get name of picture in innerHTML or input value? when spinning finished

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว

      You can calculate that by assigning different degree intervals to the different sections and then check against what degree the wheel have when it stops

    • @TheAlibaadshah
      @TheAlibaadshah 3 ปีที่แล้ว

      @@Weibenfalk good but i have not coding idea please make a video? i am just copy paste coder.

  • @zuno1406
    @zuno1406 4 ปีที่แล้ว

    I could make it transform rotation, but next click, The button could not get event 'click'. I had to reload by "F5" to rotate again.
    So, what dit I get wrong? Plz guide me that prob. Thanks a lot!

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      Hard to tell by just this info. I suggest you check the finished code from the Github repo and compare to yours. =)

    • @zuno1406
      @zuno1406 4 ปีที่แล้ว

      Thanks,
      I wonder how to calculate the finished position after ending wheel transition then show the result.
      Sorry Im a newbie.

  • @thequickcode5144
    @thequickcode5144 2 ปีที่แล้ว

    so i want to get the value ..... any logic ?🤔

    • @Weibenfalk
      @Weibenfalk  2 ปีที่แล้ว

      Got a part two for that on my channel if you search for it

  • @muhammadferozdeen7168
    @muhammadferozdeen7168 4 ปีที่แล้ว

    Hi there can i know if you have a similar wheel of fortune code that is more catered for python?

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      Hey ... I don't work with Python unfortunately =/

  • @KleberTangioni
    @KleberTangioni 3 ปีที่แล้ว

    is it possible to control which prize will be most drawn?

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว +1

      Everything is possible with code ;) But that would be cheating!

    • @KleberTangioni
      @KleberTangioni 3 ปีที่แล้ว

      @@Weibenfalk no cheating, just control!

  • @iamstojo1218
    @iamstojo1218 3 ปีที่แล้ว

    ty

  • @JaneDoe-sx9fy
    @JaneDoe-sx9fy 3 ปีที่แล้ว

    Hey is it possible to add events to this code? For exemple if it lands on a specific it’ll redirect us to a random website

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว

      Yes. You have to calculate this based on the rotation of the wheel. Every section on the wheel has a range of rotated degrees. So you can create for example a switch or an if statement that does different things depending on what range it stops in.

    • @angladephil
      @angladephil 3 ปีที่แล้ว

      I would calculate the angle each pic takes in the wheel, based on the number of pics on your wheel/360°, then knowing the value of deg defined in the code you can calculate the offset of the pic you landed on (number 1, or 2 or 3, etc ...) and according to this number then trigger whatever code you want .

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว

      @@angladephil That's a great way of doing it.

  • @hafizynadzli54
    @hafizynadzli54 4 ปีที่แล้ว

    can you add pop up box after wheel stop running

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      Hey .. you can listen for the event transitionend with JS and activate a pop up when the css transition ends.

    • @hafizynadzli54
      @hafizynadzli54 4 ปีที่แล้ว

      @@Weibenfalk help me, im newbie🙄

    • @Weibenfalk
      @Weibenfalk  4 ปีที่แล้ว

      @@hafizynadzli54 Would love to but I'm in the middle of a lot of stuff now so can't do it now I'm afraid. Google for onTransitionEnd and try to understand how it works. It's a big part of being a coder; To look things up and learn new stuff. =) So ... see it as a fun challenge for yourself and do some trial and error =) That's the best tip I can give right now.

  • @adityasaikiran.katragadda7646
    @adityasaikiran.katragadda7646 3 ปีที่แล้ว

    what is the software name
    like program software name

    • @Weibenfalk
      @Weibenfalk  3 ปีที่แล้ว

      Not sure I understand but if you mean the code editor it's Visual Studio Code

  • @goldgamermalayalam3452
    @goldgamermalayalam3452 4 ปีที่แล้ว

    Hey bro can you make it from using boostrap

    • @angladephil
      @angladephil 3 ปีที่แล้ว +1

      Hi! In my opinion : we have here very basic CSS, why the hell use a huge CSS library for this ?

  • @shaneelena4744
    @shaneelena4744 3 ปีที่แล้ว

    can you make this on wix?

  • @redaantar8908
    @redaantar8908 3 ปีที่แล้ว

    Any one know how to this in android app pls help ❤️ ?

  • @kd7542ye
    @kd7542ye 2 ปีที่แล้ว

    why are you screaming?