dcsimg
www.webdeveloper.com
Results 1 to 9 of 9

Thread: Random generator - Dice Roll with HTML5 canvas

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,290

    Random generator - Dice Roll with HTML5 canvas

    Hello

    What better than a dice to generate random numbers ?

    However, it is not very easy to roll a dice even with HTML5 canvas !
    Here is an essay which roll with drag and drop or touch and move...

    But before trying to roll it like a real Dice, I'd like to solve the problem of its shape which appears with a coloured background (see this page).

    Thank you for any comments or proposals.

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,290
    Without perspective effect, It's possible to draw something that roll and look like a dice !

    Next step, with perspective no more ellipses but many points...
    Attached Images Attached Images

  3. #3
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    795
    If you wrote that code, then I am very impressed.
    Unfortunately I am no good at 3D mathematics, or more advanced graphics in that case, to be of any help.

    I will eagerly watch your progress though.

    Good luck.
    JavaScript: Learn | Validate | Compact | bionoid

  4. #4
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,290
    Thanks ! I wrote effectively that code...
    Its' not very complicated to rotate a cube in space (see the source of 2x2x2 cube).

    This Fascinating page give me the idea of this mini Rubik's cube. I intended to propose to solve each position (It's possible with 2x2x2 - See this page ) but it's to heavy with the canvas rolling cube.

    My project is now simply to roll a dice... I discover now that Dices are not only cubes, but at first spheres...

    EDIT : Opera and safari do not appreciate my last script.
    Last edited by 007Julien; 11-10-2013 at 06:27 PM.

  5. #5
    Join Date
    Apr 2016
    Posts
    2
    How can I know which numbers are facing up after rolling is ended?

  6. #6
    Join Date
    Jul 2011
    Posts
    211
    Quote Originally Posted by amanwas View Post
    How can I know which numbers are facing up after rolling is ended?
    1. determine the results of the roll
    2. display the animated roll
    3. display the die with
    the pre determined
    results.

  7. #7
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,290
    What about this new version ?

  8. #8
    Join Date
    Aug 2015
    Posts
    1

    Thumbs up Great job

    Quote Originally Posted by 007Julien View Post
    What about this new version ?
    That looks really great. I am creating a Ludo game where I need a dice. Haven't done much 2D/3D coding myself. I will take your's as an example.

    Cheers

  9. #9
    Join Date
    Apr 2016
    Posts
    2

    How can I know which numbers are facing up?

    Can anyone please tell me how to know which numbers are facing up?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles