Dice Game - Show The Sums Of The Dices On The Screen
Nov 10, 2010
Developing a dice game. I'm totally new at this so a bit confused with the javascript language...
Anyways, heres my code:
So what i need help with is my pictures. They wont show. Firebug says: "document.getElementById("dice" + i) is null", and I have tried to solve that but with no progress...
Next step is to show the sums of the dices on the screen and also save this sums to be able to show them later on in an alert window... But that is for later, right now the dices needs to show the right (random) sides...
View 9 Replies
ADVERTISEMENT
Nov 14, 2011
Create a game where 6 dice are 'rolled' by you and 6 dice are 'rolled' by the player (simulated by the click of a button). Add up both rolls. The goal is to come as close to a score of 100 as possible, without passing 100. Have a STOP button to signify when you are ready to stop rolling and compute the winner. The highest score under 100 wins. Display the number of times you win and the number of times the computer wins using javascript. So far I have the following code, however, my dice images are not working(they display as little broken symbols when I run the game). The game itself is running just fine but I can't figure out how to get the game to do the "Add up both rolls" step and beyond.
View 1 Replies
View Related
Apr 10, 2010
I am studying webdesign and we also go through a chapter of javascript-programming. Our first assignment is to create a dice game. I have written a code and in the beginning it worked, except that all the dices showed the same random number. I tried to fix that and now I do not know what I have done! In the game, you shall click on a link and the three dices will show random numbers.
Here is my code:
View 1 Replies
View Related
Nov 16, 2009
I'm trying to make a dice game, as well as making it two player. I need to be able to have a scoreboard displayed (eg. player 1 has won 7 times and player 2 has won 4) and I need to be able to prompt the user on if they want to play the game again.
So far I have the following:
I basically just tried duplicating the original function that adds up the 'dice'. But it doesn't work, I've tried playing around with if/else statements etc to get it to display messages and so fourth, but I have failed.
View 1 Replies
View Related
Dec 9, 2011
How to make a dice game for two player in javascript and html using just two dice?
1. Each player throws both dice once per turn. You only score if you throw doubles (that is, both dice have the same number of spots on their top face).
2. Players score five points for double ones, twos, fours or fives. A double six scores twenty five points, but if you throw a double three your score goes back to zero.
3. Add your score as you play. The first player to get fifty points wins the game. (An adult or older child may need to help score, but you can use this game to teach younger children to count by fives.)
View 3 Replies
View Related
Jun 10, 2009
I am just about finished the dice game but am having trouble doing the calculation where if a player wins then they double their venture. I am not too sure how the game stores what the user picks in their venture 100 or 200.
I am already subtracting their venture from the total when they initially make their venture. But if they win then I need to add back the venture to the total by 2. Not too sure how to do this. Do I use a new function. How can I tell which button the user chooses 100 or 200 and then add on that amount.
[Code]...
View 6 Replies
View Related
Nov 15, 2009
Im trying to make a dice game. how to get started n stuff. Something that will create a random number b/w 1 n 6 and decide if the user is a winner. He will win only if the #s are equal
So i want a text box for the first number and text box for the second. a button to click to play the game(roll the dice) button to start over and reset all values textbox to display the # of tries(rolls) textbox 2 display the # of wins. Also i want toKeep track of the number of times the user rolls the dice and display this in the appropriate textbox and the number of times the user wins the game and display this in the appropriate textbox.
Well my friend helped me with this but he made 2 player i only want one player and i want the number of tries and win the user wins if the #s are equal and i want a start over button that resets everything. Also the max number i want is 6 and only one roll the dice button but 2 textboxes so if you get same # you win it should appear in alert and text box for tries and wins. Also, i am gonna have 2 pics one for the first textbox the other for the second both of the pics are gonna be dice and i am gonna have 12 pics but only 2 appear at a time so if a guy gets 5 the dice with the #5 appears and the other text gets 4 the dice with the # 4 appears
<html>
View 26 Replies
View Related
Mar 7, 2011
Before I go on, I should state that I know little of Javascript - tried learning it once, but it was way over my head.
On to the problem: I found a script that will roll dice and post the results to the page. In my case, everything is working except for the fact it doesn't post the results.
Here is the dice roller: [url]
What it should be doing: [url]
I've sent a message to it's creator, but he hasn't responded yet. I'm not sure what exactly the problem is, so I won't post the page source here (it can get fairly long).
View 4 Replies
View Related
Mar 10, 2011
I was trying to make a Javascript game that moves an image across the screen randomly. Instead of executing properly, it just shows the image's starting point, and stops. No movement.
View 1 Replies
View Related
Feb 4, 2011
I have been able to create the basis of a form for my Skittle League which will allow teams to submit results over the web.I have one calculation to complete before I look to make the form live and I am hoping someone can provide the final peice of the jigsaw.URL...The form adds togther the 5 values for each half for each team and places them in a Half Total box below.The form adds together the two totals for each half for each team then places them in a Total box below.I have been able to add a operation using the onchange event the points are automatically calculated for each half and total, depending on the overall scores, 2 points for a win, 1 for a draw 0 for a loss.What I'm struggling to do is add the three points totals together to generate the Overall Points for a team and place them in a text box at the top of the scoresheet (marked xxx on the page).Also is it possible to combine the sums into one script therefore reduing the overall size.
View 8 Replies
View Related
Sep 20, 2009
Formfield.anzahl1 = number entered by customer
Formfield.Price1 = Ergebnisfeld1
e.g.
Anzahl1= 1
Price = 270
*if Anzahl1 = 2 then Price = 270*2
I need to do this for two form option. 2nd field would be as follows
Formfield.Anzahl2= number entered by customer
Formfield.Price2 = Ergebnisfeld2
Then Formfield.Total = Ergebnisfeld1 + Ergebnisfeld2
How can I convert these above to javascript?
View 1 Replies
View Related
Jul 26, 2011
how to resize a screen using javascript to show at 1024by768.
View 5 Replies
View Related
Dec 29, 2003
I was wondering if you had any idea how to show a ad based on screen resolution. Sort of like how espn.com has it...when your on 800 by 600 it doesn't show the ad and msn table on the right but when you are on 1024 or higher it does. Does anyone have any idea how to do this?
View 1 Replies
View Related
Dec 7, 2005
I have a form with several different text boxes for things like dates,
numbers, etc. arranged in a table, each row has the same kind of text
boxes for data entry (10 rows probably).
I want to have a separate section above the form where I can toggle a
div containing an appropriate error message to appear after the
onchange event fires for the text box.
The thing is, I want all the divs with their different text messages to
appear in the same place and disappear from the same place above the
form instead of different places on the form or web page.
Well, they don't have to be multiple divs, but there are multiple
different error messages that should appear depending where the user is
typing...
Example: 'wrong format,' 'month must be between 1 and 12,' etc. Of
course the messages will be nicer than this.
View 5 Replies
View Related
Dec 19, 2011
I want to create an overlay to show a photo in the middle of the screen with a navigation menu. As overlay I use something like:
.overlay {
position: absolute;
top: 0;
left: 0;
[Code].....
View 2 Replies
View Related
Mar 24, 2011
I am supposed to create a calendar and have the calendar show up in the top right of the screen while also highlighting the current date set on it.
Nothing shows up...
HTM:
View 3 Replies
View Related
Dec 16, 2009
I have a page, which is actually a photo gallery with a table having 3 rows. First row shows the full screen size pic. Second row displays the Caption of that image and third row shows thumbnail view of six different images and the previous and next button.this is the sample layout:
<table>
<tr>
<td colspan=8>
[code]...
My requirement is whenever the user click on the thumbnail view, which is in the 3rd row, the corresponding full screen size pic should open in 1st row of the table.As my photo gallery should be having more than 6 pics, lets take 20 pics, I want to show only 6 thumbnails in 3rd row at a time. Whenever user press "Next" button the 3rd row having 6 thumbnails should show other 6 thumbnails and previous button should show previous 6 thumbnails.
View 10 Replies
View Related
Jul 14, 2010
iv been using a tutorial to creaete the script to show an enlarged version of an image float on the screen on mouse over. the script and everything else works but i was wondering if someone could help me to make the floating image more central as it floats down and right.
03-20-2007, 11:32 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Caption Hover</title>
[Code]...
View 1 Replies
View Related
Nov 5, 2004
I am having trouble creating a page that stimulates a large number of dice rolls and computes the average of the dice totals in an separate text box. Code:
View 1 Replies
View Related
Mar 30, 2009
I'm making a dice program, that randomly draws x amount of times for x sided die. I decided to add on a "history" feature to this program--displaying the previous rolls (unlimited I imagine) and to show the math that comes from that equation. Everything works perfect except for the history function.
I've got a div area sectioned off with the id divhistory. At the end of the dice rolling program it calls function fhistory(z). Where z is the string that displays the random rolls and total (1 + 3 + 2 = 6).
Heres the code I've been fusing over. I imagine it's horribly off--but I'm also terrible with arrays it seems...
View 2 Replies
View Related
Mar 28, 2009
Im currently taking some computer science courses in university and kind of enjoy this javascript stuff! im trying to figure out this final program...
Here is what is needed: Enhance the previous example, so the user can bet on the outcome of the roll, i.e. she can try to guess if the roll is going to be even or odd. If the user makes the right guess, she wins the amount of the bet, otherwise she loses the amount of the bet. The initial value of the wallet should be 100.
You should use 3 functions for this exercise. One function is executed when the user presses the button. The other functions (win and lose) are called by the first function when the user wins or loses.
This is the code i have so far. The "first function" was working perfectly. Now not only will the picture not show up when the "Roll!" button is pressed, but i cant figure out the even and odd assignments.
View 14 Replies
View Related
Oct 30, 2011
I am taking a JavaScript class and I am currently on an assignment where my Professor wants me to create a dice roller program with the following stipulations:
Now to the problems. I have set up to where it will take the form, pass it to my "sidecheck" function, but I do not think it is passing it to the Die() function to roll the die. As far as the output part of it to show roll totals and percentages, I am lost on that one.
Below is my code and what I have so far.
View 1 Replies
View Related
Mar 5, 2007
Same thing for the height parameter; for to set in the centre some popup with images what is better? what are the difference?
View 6 Replies
View Related
Mar 2, 2011
I have 2 monitors from a different size. It is important in my application that I get the screen size of the monitor where the webbrowser is located. When I try to get the screen size (window.screen.height + window.screen.width) only IE gives me always the screen size of the main monitor where my taskbar (windows7) is located, instead of the screen size of the secondary screen where the webbrowser is located.
View 6 Replies
View Related
Dec 27, 2011
I have a div that has a negative top margin and a negative right margin. The right margin is because I want to have the div slide onto the page from the right. The top margin is because without it my page height is the height of the visible elements plus the height of the off-screen div.On a button click, I move the div down and then animate it onto the screen from the right. On button click again, I animate the div to the right, off the screen, and then move it up. I also toggle its width & padding so it will appear to grow/shrink as it moves on/off screen. At least that's what I am trying to do. The animation onto the screen looks good, but going off the screen, it appears to happen intantaneously, instead of animatedDoes anyone know how I can fix this?
$(".addPanels").live("click", function(){//now and in the future, show the add panels menu
var thisAddPanelsMenu = $(this).parent().prev(".addPanelsMenu");//get the addPanelsMenu
if(thisAddPanelsMenu.length) {//if the addPanelsMenu exists
[code]....
View 2 Replies
View Related
Oct 3, 2003
Have a look at this maths game I made. It tests you on adding, subtracting, multiplying and dividing and has three different levels.
Note-you must save the code below as mathsgamefinal.htm for the reset button to work.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-gb">
<title></title>
</head>
<body bgcolor="#FF0000">
<script type="text/javascript">
function next1(){
var outof=document.getElementById('outof').value;
if(document.getElementById('next').value=="Next" && document.getElementById('type').value=="a"){document.getElementById('next').value='Enter' add(); document.getElementById('answer').value='answer'}
else if(document.getElementById('next').value=="Next" && document.getElementById('type').value=="m"){document.getElementById('next').value='Enter' times(); document.getElementById('answer').value='answer'}
else if(document.getElementById('next').value=="Next" && document.getElementById('type').value=="t"){document.getElementById('next').value='Enter' minus(); document.getElementById('answer').value='answer'}
else if(document.getElementById('next').value=="Next" && document.getElementById('type').value=="d"){document.getElementById('next').value='Enter' divide(); document.getElementById('answer').value='answer'}
else if(document.getElementById('next').value=="Enter" && document.getElementById('answer').value==(cr)){ document.getElementById('question').value='Correct' document.getElementById('next').value='Next' document.getElementById('outof').value=parseInt(document.getElementById('outof').value)+1; document.getElementById('score').value=parseInt(document.getElementById('score').value)+1; pc();}
else{ document.getElementById('question').value='Wrong. Answer= '+cr; document.getElementById('next').value='Next' document.getElementById('outof').value=parseInt(document.getElementById('outof').value)+1; pc();}
document.getElementById('answer').select();
}
function add(){
ea1=(Math.floor(Math.random() * (1 - 10)) + 10);
ea2=(Math.floor(Math.random() * (1 - 10)) + 10);
ma1=(Math.floor(Math.random() * (21 - 49)) + 49);
ma2=(Math.floor(Math.random() * (21 - 49)) + 49);
ha1=(Math.floor(Math.random() * (111 - 299)) + 299);
ha2=(Math.floor(Math.random() * (111 - 299)) + 299);
if(document.getElementById('level').value=="e"){document.getElementById('question').value=ea1+' plus '+ea2; cr=ea1+ea2}
if(document.getElementById('level').value=="m"){document.getElementById('question').value=ma1+' plus '+ma2; cr=ma1+ma2}
if(document.getElementById('level').value=="h"){document.getElementById('question').value=ha1+' plus '+ha2; cr=ha1+ha2}
}
function times(){
em1=(Math.floor(Math.random() * (2 - 10)) + 10);
em2=(Math.floor(Math.random() * (2 - 10)) + 10);
mm1=(Math.floor(Math.random() * (11 - 19)) + 19);
mm2=(Math.floor(Math.random() * (6 - 12)) + 12);
hm1=(Math.floor(Math.random() * (21 - 29)) + 29);
hm2=(Math.floor(Math.random() * (21 - 29)) + 29);
if(document.getElementById('level').value=="e"){document.getElementById('question').value=em1+' times '+em2; cr=em1*em2}
if(document.getElementById('level').value=="m"){document.getElementById('question').value=mm1+' times '+mm2; cr=mm1*mm2}
if(document.getElementById('level').value=="h"){document.getElementById('question').value=hm1+' times '+hm2; cr=hm1*hm2}
}
function minus(){
et1=(Math.floor(Math.random() * (10 - 20)) + 20);
et2=(Math.floor(Math.random() * (1 - 10)) + 10);
mt1=(Math.floor(Math.random() * (50 - 99)) + 99);
mt2=(Math.floor(Math.random() * (20 - 50)) + 50);
ht1=(Math.floor(Math.random() * (350 - 1000)) + 1000);
ht2=(Math.floor(Math.random() * (350 - 1000)) + 1000);
if(document.getElementById('level').value=="e"){document.getElementById('question').value=et1+' minus '+et2; cr=et1-et2}
if(document.getElementById('level').value=="m"){document.getElementById('question').value=mt1+' minus '+mt2; cr=mt1-mt2}
if(document.getElementById('level').value=="h"){document.getElementById('question').value=ht1+' minus '+ht2; cr=ht1-ht2}
}
function divide(){
ed1=(Math.floor(Math.random() * (2 - 10)) + 10);
ed2=(Math.floor(Math.random() * (2 - 10)) + 10);
md1=(Math.floor(Math.random() * (11 - 19)) + 19);
md2=(Math.floor(Math.random() * (11 - 19)) + 19);
hd1=(Math.floor(Math.random() * (21 - 29)) + 29);
hd2=(Math.floor(Math.random() * (21 - 29)) + 29);
ed3=ed1*ed2;
md3=md1*md2;
hd3=hd1*hd2;
if(document.getElementById('level').value=="e"){document.getElementById('question').value=ed3+' divided by '+ed2; cr=ed1}
if(document.getElementById('level').value=="m"){document.getElementById('question').value=md3+' divided by '+md2; cr=md1}
if(document.getElementById('level').value=="h"){document.getElementById('question').value=hd3+' divided by '+hd2; cr=hd1}
}
function answerreset(){
if(document.getElementById('answer').value=="answer"){document.getElementById('answer').value=''}
}
function pc(){
document.getElementById('scorepercent').value=document.getElementById('score').value/document.getElementById('outof').value*100;
document.getElementById('scorepercent').value=Math.round(document.getElementById('scorepercent').val ue);
}
</script>
<table border="0" width="198" height="180" bordercolor="#000000" style="background-color: #FFFF00; border-style: solid">
<tr>
<td height="33" width="99" colspan="2">
<p align="center">
<select size="1" name="type" id='type'>
<option value="a" selected>Add</option>
<option value="t">Take away</option>
<option value="m">Multiply</option>
<option value="d">Divide</option>
</select></p>
</td>
<td height="36" width="99" colspan="2">
<p align="center">
<select size="1" name="level" id=level>
<option value="e" selected>Easy</option>
<option value="m">Medium</option>
<option value="h">Hard</option>
</select></p>
</td>
</tr>
<tr>
<td height="36" width="198" colspan="4">
<p align="left">
<input type="button" name="T1" id='question' value="Click next to begin" style="background-color: #FFFF00; border: 0 solid #FFFF00">
</p>
</td>
</tr>
<tr>
<td height="33" width="66">
<p align="center"><input type="text" name="answer" size="6" id='answer' onclick=answerreset()></td>
<td height="36" width="66" colspan="2">
<p align="center"><button onclick='next1()' id='next'>Next</button></td>
<td height="33" width="66">
<p align="center"><button onclick='window.location="mathsgamefinal.htm"'>Reset</button></td>
</tr>
<tr>
<td height="36" width="66">
<p align="center">Score %:</td>
<td height="33" width="66" colspan="2">
<p align="center">Score Marks:</td>
<td height="33" width="66">
<p align="center">Out of:</td>
</tr>
<tr>
<td height="33" width="66">
<p align="center"><input type="button" name="T1" size="3" id=scorepercent value="0"></td>
<td height="33" width="66" colspan="2">
<p align="center"><input type="button" name="score" size="3" id=score value="0"></td>
<td height="36" width="66">
<p align="center"><input type="button" name="outof" size="3" id=outof value="0"></td>
</tr>
</table>
</body>
</html>
Any feedback would be much apprieciated...
View 6 Replies
View Related