Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.  
  3.     <head>
  4.    
  5.         <title>Reaction Test Game</title>  
  6.        
  7.         <style type="text/css">
  8.        
  9.             #text {
  10.            
  11.             }
  12.        
  13.             #shape1 {              
  14.                 width: 200px;
  15.                 height: 200px;
  16.                 background-color: red;
  17.                            
  18.             }
  19.        
  20.             .square {
  21.                
  22.                            
  23.                
  24.             }
  25.            
  26.             .circle {              
  27.                 border-radius: 50%;
  28.                 background-color: red;
  29.             }
  30.            
  31.            
  32.        
  33.        
  34.         </style>
  35.    
  36.    
  37.     </head>
  38.    
  39.     <body>
  40.    
  41.         <div id=text>
  42.    
  43.             <h1>Test your reactions!</h1>
  44.            
  45.             <p>Click on the boxes and circles as quick as you can!</p>
  46.            
  47.             <h4>Your time: </h4>
  48.        
  49.         </div>     
  50.        
  51.         <div id="shape1"></div>
  52.        
  53.         <script type="text/javascript">
  54.        
  55.             function randomBoxOrCircle() {
  56.            
  57.                 var shape = document.getElementById("shape1");
  58.                 console.log(shape);
  59.                
  60.                 if (Math.random()<=0.5){
  61.                     shape.className = "square";
  62.                     //console.log(shape);
  63.                    
  64.                 } else {
  65.                     shape.className = "circle";
  66.                     //console.log(shape);
  67.                 }              
  68.            
  69.             }
  70.            
  71.             function generateRandomNumber(maximumValue) {
  72.            
  73.                 var number = Math.floor(Math.random() * maximumValue + 1);
  74.                 return number;
  75.             }
  76.            
  77.             function generateNewShape() {
  78.                 randomBoxOrCircle();
  79.                 var test = document.getElementById("shape1").style.backgroundColor = "rgb("+generateRandomNumber(255)+", "+generateRandomNumber(255)+", "+generateRandomNumber(255)+")";
  80.                 console.log(test); 
  81.             }
  82.            
  83.            
  84.                        
  85.             generateNewShape();    
  86.            
  87.        
  88.        
  89.         </script>      
  90.    
  91.        
  92.    
  93.    
  94.     </body>
  95.  
  96.  
  97. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement