Added start game button
Now the game does not start automatically and there's no need to refresh
This commit is contained in:
		
							parent
							
								
									99a5968fbd
								
							
						
					
					
						commit
						1a8add76d8
					
				
							
								
								
									
										19
									
								
								index.html
								
								
								
								
							
							
						
						
									
										19
									
								
								index.html
								
								
								
								
							|  | @ -4,8 +4,27 @@ | ||||||
|     <meta charset="UTF-8"> |     <meta charset="UTF-8"> | ||||||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0"> |     <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||||
|     <title>Rock Paper Scissors</title> |     <title>Rock Paper Scissors</title> | ||||||
|  |     <style> | ||||||
|  |         button { | ||||||
|  |             margin: 50px; | ||||||
|  |             position: absolute; | ||||||
|  |             top: calc(50% - 50px); | ||||||
|  |             left: calc(50% - 50px); | ||||||
|  |             padding: 20px; | ||||||
|  |             border: 2px solid #000; | ||||||
|  |             border-radius: 35px; | ||||||
|  |             background-color: #444; | ||||||
|  |             color: #fff; | ||||||
|  |             font-weight: 700; | ||||||
|  |             font-size: xx-large; | ||||||
|  |             cursor: pointer; | ||||||
|  |             transform: translate(-50%, -50%); | ||||||
|  |             display: block; | ||||||
|  |         } | ||||||
|  |     </style> | ||||||
| </head> | </head> | ||||||
| <body> | <body> | ||||||
|  |     <button onclick="game(this)">Start<br>game</button> | ||||||
|     <script src="index.js"></script> |     <script src="index.js"></script> | ||||||
| </body> | </body> | ||||||
| </html> | </html> | ||||||
							
								
								
									
										6
									
								
								index.js
								
								
								
								
							
							
						
						
									
										6
									
								
								index.js
								
								
								
								
							|  | @ -43,7 +43,8 @@ const points = (() => { | ||||||
|             playerAddPoints, computerAddPoints, reset}; |             playerAddPoints, computerAddPoints, reset}; | ||||||
| })() | })() | ||||||
| 
 | 
 | ||||||
| function game() { | function game(clickEvent) { | ||||||
|  |     clickEvent.setAttribute('onclick', ' '); | ||||||
|     points.reset(); |     points.reset(); | ||||||
| 
 | 
 | ||||||
|     for (let i = 0; i < 5; i++) { |     for (let i = 0; i < 5; i++) { | ||||||
|  | @ -60,6 +61,7 @@ function game() { | ||||||
|                     } |                     } | ||||||
|                 }) |                 }) | ||||||
|             } else if (confirm(`Do you wanna quit the game?`)) { |             } else if (confirm(`Do you wanna quit the game?`)) { | ||||||
|  |                 clickEvent.setAttribute('onclick', 'game(this)'); | ||||||
|                 throw new Error("Exited the game on user's request"); |                 throw new Error("Exited the game on user's request"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | @ -82,4 +84,4 @@ function game() { | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| game(); | // game();
 | ||||||
		Loading…
	
		Reference in New Issue