/    Sign up×
Community /Pin to ProfileBookmark

Code to roll a dice

I have a simple home page that I would like to spice up a little. I have some programming experience in VB and Unix scripts, but none in Java scripts. I need some code to roll a die (dice) when someone clicks on die.

Here is what I am looking for…

1.Click on the die and it spins.
2.When it stops spinning is shows a random number based on a specific range. i.e. 21 –30

Notes…
·I would like a square red die with yellow text
·Code to add other effects while spinning would be nice, but not necessary
·I will be using the code to create several dice with different colors and number ranges

Thanks,

Nick

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@NatdripJul 21.2006 — it would probably be easier if you use flash...

the code for this doen't seem that difficult but the images are the

if you want me to help you what I need from you are all the possible die faces in gif format and one animated .gif that shows the die in motion then build an array that holds the names of all the die .gif then you will need to construct a random() function for the die values once you get these values you will then need to run the animation function where the outcome puts the .gif die face value that coinside with the generated random() values.

ie. array("one.gif","two.gif")

random (1)

array[1]

play the dice animated gif. for a few sec then swap with still img die "one.gif"

once you get as far as you can and you need help scripting it... me and or someone else will help you ?
Copy linkTweet thisAlerts:
@ndel40authorJul 21.2006 — What if there was no image, just a simple red square box that spins 360 degrees? After the spin (rotation) has competed a random number between a specified range appears in the box.

I want to keep it very simple.

I have done what I want in Excel using VB code... I can send the file to you if you think it will help.

Thanks!
×

Success!

Help @ndel40 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...