Dice roller!

This is a discussion on "Dice roller!" within the JavaScript Forum section. This forum, and the thread "Dice roller! are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 20th, 2007, 18:01
New Member
Join Date: Nov 2007
Location: NY
Age: 23
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Dice roller!

Hey, im about a create a dice-roller game but don't know how to move on. The game needs to contain vars, functions, if statements, arrays and for loops. I've got 6 images in a .gif format.

The goals I want to archive:

- Got 3 dices, each shall be thrown individually.
- There shall be a button to throw all dices.
- When the "Throw all"-button is pressed a result shall be shown.
- You only get points when you get 2 or 3 dices of same kind, else the score is 0. If you get 3 dices of same kind you get the points * 2. (Could be done with a if-statement).
- An Array shall be used to save the scores from the rounds when you get points.
- To display the total score you make another button with an Alert function containing all the results in a text-string and the sum of all results togheter.

Thats about all... I've started but, as I said, I dont know how to move on.

At the moment the result of all dices are written and i cant thrown them individually.

Hope someone can help me, Cheers!

PHP: Select all

window.onload = function() 

document.getElementById("button_throw").onclick = function() 

var 
itotal 0randomtotalp

for (
1<= 3i++) 

random Math.floor(1+Math.random()*6);
document.getElementById("dice" i).src random ".gif"

total += random


totalp document.getElementById("dice_total"); 
totalp.replaceChild(document.createTextNode("Result: " total), totalp.firstChild); 


PHP: Select all

<p><button id="button_throw">Throw all dices</button

<
p id="dices_images"
<
img src="1.gifid="dice1"
<
img src="1.gifid="dice2"
<
img src="1.gifid="dice3"

<
p id="dice_total"
Reply With Quote

  #2 (permalink)  
Old Nov 20th, 2007, 18:11
Reputable Member
Join Date: Nov 2007
Location: India
Posts: 150
Blog Entries: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Dice roller!

You should use arrays with randomizing functions.
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)
Reply With Quote
  #3 (permalink)  
Old Nov 20th, 2007, 18:18
New Member
Join Date: Nov 2007
Location: NY
Age: 23
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Dice roller!

Quote:
Originally Posted by RohanShenoy View Post
You should use arrays with randomizing functions.
Can you show me how to do that, im still learning and need some guidance.
Reply With Quote
  #4 (permalink)  
Old Nov 21st, 2007, 14:20
Reputable Member
Join Date: Nov 2007
Location: India
Posts: 150
Blog Entries: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Dice roller!

On clicking the throw dice,

1. One function must be called to throw dice one. This same function will define the value of variable assigned to the score for dice 1.
2. One function as dice 2.
3. One function for dice 3.
4. One function to up three scores
5. One IF ELSE statement to double the score if all are same.
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rim roller Ecthelion Free Web Site Critique 22 Mar 15th, 2007 07:53
Roller/brushstroke effects in Fireworks minute44 Graphics and 3D 4 Sep 5th, 2006 18:12


All times are GMT. The time now is 01:14.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43