mirror of
https://github.com/MrEidam/PetPet.git
synced 2026-04-17 15:43:31 +00:00
Big Boy update, wallpaper, sad escape, games, icon
This commit is contained in:
18
Games/RockPaperScissors/index.html
Normal file
18
Games/RockPaperScissors/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="main.js"></script>
|
||||
<title>Rock Paper Scisors</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="opponent-score">0</h1>
|
||||
<img id="opponent-choice">
|
||||
<br>
|
||||
<img id="your-choice">
|
||||
<div id="choices"></div>
|
||||
<h1 id="your-score">0</h1>
|
||||
</body>
|
||||
</html>
|
||||
55
Games/RockPaperScissors/main.js
Normal file
55
Games/RockPaperScissors/main.js
Normal file
@@ -0,0 +1,55 @@
|
||||
let you;
|
||||
let playerScore = 0;
|
||||
|
||||
let opponent;
|
||||
let opponentScore = 0;
|
||||
|
||||
const choices = ["rock", "paper", "scissors"];
|
||||
|
||||
window.onload = () => {
|
||||
for(let i=0;i<3;i++){
|
||||
let choice = document.createElement("img");
|
||||
choice.id = choices[i];
|
||||
choice.src = `${choices[i]}.png`;
|
||||
choice.addEventListener("click", selectChoice);
|
||||
document.getElementById("choices").append(choice);
|
||||
}
|
||||
}
|
||||
|
||||
function selectChoice(){
|
||||
you = this.id;
|
||||
document.getElementById("your-choice").src = `${you}.png`;
|
||||
|
||||
opponent = choices[Math.floor(Math.random()*3)];
|
||||
document.getElementById("opponent-choice").src = `${opponent}.png`;
|
||||
|
||||
if(you===opponent){
|
||||
playerScore++;
|
||||
opponentScore-=-1;
|
||||
}else{
|
||||
if(you==="rock"){
|
||||
if(opponent==="paper"){
|
||||
opponentScore++;
|
||||
}
|
||||
if(opponent==="scissors"){
|
||||
playerScore++;
|
||||
}
|
||||
}else if(you === "paper"){
|
||||
if(opponent==="rock"){
|
||||
playerScore++;
|
||||
}
|
||||
if(opponent==="scissors"){
|
||||
opponentScore++;
|
||||
}
|
||||
}else{
|
||||
if(opponent==="rock"){
|
||||
opponentScore++;
|
||||
}
|
||||
if(opponent==="paper"){
|
||||
playerScore++;
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById("opponent-score").innerHTML = opponentScore;
|
||||
document.getElementById("your-score").innerHTML = playerScore;
|
||||
}
|
||||
BIN
Games/RockPaperScissors/paper.png
Normal file
BIN
Games/RockPaperScissors/paper.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 176 KiB |
BIN
Games/RockPaperScissors/rock.png
Normal file
BIN
Games/RockPaperScissors/rock.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
BIN
Games/RockPaperScissors/scissors.png
Normal file
BIN
Games/RockPaperScissors/scissors.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 310 KiB |
33
Games/RockPaperScissors/style.css
Normal file
33
Games/RockPaperScissors/style.css
Normal file
@@ -0,0 +1,33 @@
|
||||
body{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
img{
|
||||
aspect-ratio: 1/1;
|
||||
}
|
||||
|
||||
#opponent-choice{
|
||||
width: 240px;
|
||||
height: 240px;
|
||||
/*background: #fcda45;*/
|
||||
margin-top: 10px;
|
||||
}
|
||||
#your-choice{
|
||||
width: 240px;
|
||||
height: 240px;
|
||||
/*background: #4fdc5e;*/
|
||||
margin-top: 10px;
|
||||
}
|
||||
#choices{
|
||||
width: 240px;
|
||||
height: 80px;
|
||||
/*background: #f4a478;*/
|
||||
margin: 0 auto;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#choices img{
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
}
|
||||
Reference in New Issue
Block a user