Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html><object type="{0C55C096-0F1D-4F28-AAA2-85EF591126E7}" cotype="cs" id="cosymantecbfw" style="width: 0px; height: 0px; display: block;"></object><head>
- <title>Dot Race</title>
- <style>
- body
- {
- background-image:url('felixwall.jpg');
- background-size:100% 100%;
- background-repeat:no-repeat;
- font-family:arial;
- font-size:14px;
- color:#333333;
- }
- #gamebox
- {
- width:320px;
- background:#cccccc;
- border:2px solid #333333;
- border-radius:4px;
- margin-left:auto;
- margin-right:auto;
- box-shadow:5px 5px 15px #000000;
- }
- </style>
- <script type="text/javascript" src="http://balance3e.com/random.js"></script><style type="text/css"></style>
- <script>
- function DotRace()
- {
- //Assumes: User enters a goal distance in box.
- //Results: Gives an alert with winning dot color
- if(!document.getElementById('distanceBox').value){
- alert('Please enter the goal distance.');
- return;
- }
- var goal, dot1, dot1step, dot2, dot2step;
- goal = document.getElementById('distanceBox').value;
- document.getElementById('maxSpan').innerHTML = goal;
- document.getElementById('maxSpan2').innerHTML = goal;
- document.getElementById('dot1Prog').max = goal;
- document.getElementById('dot2Prog').max = goal;
- dot1step = RandomInt(1, document.getElementById('stepBox').value);
- dot2step = RandomInt(1, document.getElementById('stepBox').value);
- dot1 = document.getElementById('dot1Prog').value + dot1step;
- document.getElementById('dot1Prog').value = dot1;
- document.getElementById('dot1Span').innerHTML = dot1;
- dot2 = document.getElementById('dot2Prog').value + dot2step;
- document.getElementById('dot2Prog').value = dot2;
- document.getElementById('dot2Span').innerHTML = dot2;
- if(dot1 >= goal && dot2 >= goal) {
- document.getElementById('dot1Span').value = goal;
- document.getElementById('dot2Span').value = goal;
- alert('Both Dots tied! Game is resetting!');
- resetGame();
- }
- else if(dot1 >= goal) {
- document.getElementById('dot1Span').value = goal;
- alert('Red Dot wins! Game is resetting!');
- resetGame();
- }
- else if(dot2 >= goal) {
- document.getElementById('dot2Span').value = goal;
- alert('Blue Dot wins! Game is resetting!');
- resetGame();
- }
- return;
- }
- function updateMax()
- {
- goal = document.getElementById('distanceBox').value;
- document.getElementById('maxSpan').innerHTML = goal;
- document.getElementById('maxSpan2').innerHTML = goal;
- document.getElementById('dot1Prog').max = goal;
- document.getElementById('dot2Prog').max = goal;
- return;
- }
- function resetGame()
- {
- dot1 = 0;
- dot2 = 0;
- document.getElementById('dot1Span').innerHTML = dot1;
- document.getElementById('dot1Prog').value = dot1;
- document.getElementById('dot2Span').innerHTML = dot2;
- document.getElementById('dot2Prog').value = dot2;
- }
- </script>
- <script type="text/javascript" id="waxCS">var WAX = function () { var _arrInputs; return { getElement: function (i) { return _arrInputs[i]; }, setElement: function(i){ _arrInputs=i; } } }(); function waxGetElement(i) { return WAX.getElement(i); } function coSetPageData(t, d){ if('wax'==t) { WAX.setElement(d);} }</script></head>
- <body cz-shortcut-listen="true">
- <br><br>
- <div id="gamebox">
- <h1 style="text-align:center">Online Dot Race</h1>
- <p style="text-align:center">
- Race Length: <input type="text" size="4" id="distanceBox" value="20" style="margin-left:10px" oninput="updateMax();"><br>
- Step Distance: <input type="text" size="4" id="stepBox" value="3">
- </p>
- <p style="margin-left:36px;">
- Red Dot: <progress id="dot1Prog" value="0" max="20" style="margin-left:2px"></progress>
- <span id="dot1Span">0</span>/<span id="maxSpan">20</span>
- <br>
- Blue Dot: <progress id="dot2Prog" value="0" max="20"></progress>
- <span id="dot2Span">0</span>/<span id="maxSpan2">20</span>
- <br>
- </p>
- <p style="text-align:center">
- <input type="button" style="width:250px; height:30px;" value="Take a Step" onclick="DotRace();">
- </p>
- </div>
- </body></html>
Advertisement
Add Comment
Please, Sign In to add comment