# Thread: Random generator - Dice Roll with HTML5 canvas

1. Registered User
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. Registered User
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...

3. 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.

4. Registered User
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. Registered User
Join Date
Oct 2010
Location
Versailles, France
Posts
1,290

6. Registered User
Join Date
Aug 2015
Posts
1

## Great job

Originally Posted by 007Julien
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

7. Registered User
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?

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

9. Spasmodic User
Join Date
Jul 2011
Posts
211
Originally Posted by amanwas
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.

10. Registered User
Join Date
May 2017
Posts
2
That looks great but is too difficult to upgrade by me. Who know and upgrade this code that first program set random number from 1 to 6 show this number in F12 console and next the dice animate roll and stop on this number.

11. Registered User
Join Date
May 2017
Posts
2

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
•

"

"

## X vBulletin 4.2.2 Debug Information

• Page Generation 0.11347 seconds
• Memory Usage 2,954KB
• Queries Executed 16 (?)
Template Usage (34):
• (2)bbcode_quote
• (1)footer
• (1)forumjump
• (1)forumrules
• (1)gobutton
• (11)memberaction_dropdown
• (1)navbar
• (1)navbar_moderation
• (1)navbar_noticebit
• (1)navbar_tabs
• (2)option
• (11)postbit
• (1)postbit_attachment
• (11)postbit_onlinestatus
• (11)postbit_wrapper
• (1)spacer_close
• (1)spacer_open
• (1)tagbit_wrapper

Phrase Groups Available (6):
• global
• inlinemod
• postbit
• posting
• reputationlevel
Included Files (26):
• ./global.php
• ./includes/class_bootstrap.php
• ./includes/init.php
• ./includes/class_core.php
• ./includes/config.php
• ./includes/functions.php
• ./includes/class_friendly_url.php
• ./includes/class_hook.php
• ./includes/class_bootstrap_framework.php
• ./vb/vb.php
• ./vb/phrase.php
• ./includes/functions_calendar.php
• ./includes/functions_bigthree.php
• ./includes/class_postbit.php
• ./includes/class_bbcode.php
• ./includes/functions_reputation.php
• ./includes/functions_notice.php
• ./packages/vbattach/attach.php
• ./vb/types.php
• ./vb/cache.php
• ./vb/cache/db.php
• ./vb/cache/observer/db.php
• ./vb/cache/observer.php

Hooks Called (74):
• init_startup
• friendlyurl_resolve_class
• init_startup_session_setup_start
• database_pre_fetch_array
• database_post_fetch_array
• init_startup_session_setup_complete
• global_bootstrap_init_start
• global_bootstrap_init_complete
• cache_permissions
• fetch_postinfo_query
• fetch_postinfo
• fetch_foruminfo
• global_state_check
• global_bootstrap_complete
• global_start
• style_fetch
• global_setup_complete
• strip_bbcode
• friendlyurl_clean_fragment
• friendlyurl_geturl
• forumjump
• cache_templates
• cache_templates_process
• template_register_var
• template_render_output
• fetch_template_start
• fetch_template_complete
• parse_templates
• notices_check_start
• notices_noticebit
• process_templates_complete
• friendlyurl_redirect_canonical
• fetch_postattach_query
• bbcode_fetch_tags
• bbcode_create
• postbit_factory
• postbit_display_start
• postbit_imicons
• bbcode_parse_start
• bbcode_parse_complete_precache
• bbcode_parse_complete
• postbit_display_complete
• memberaction_dropdown
• postbit_attachment
• tag_fetchbit_complete
• forumrules
• navbits
• navbits_complete