|
| 1 | +<html> |
| 2 | +<head> |
| 3 | + <meta charset="UTF-8"> |
| 4 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="ie=edge"> |
| 6 | + |
| 7 | + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" /> |
| 8 | + <script src="https://cdn.tailwindcss.com"></script> |
| 9 | + <title>RPS</title> |
| 10 | + <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> |
| 11 | + |
| 12 | +</head> |
| 13 | + |
| 14 | +<body> |
| 15 | + |
| 16 | +<div id="app"> |
| 17 | + |
| 18 | + |
| 19 | +<div class="grid grid-cols-3 pt-20 mx-auto max-w-lg min-h-[22%]"> |
| 20 | +<div class="text-center"> |
| 21 | +<i class="fa-solid fa-user text-5xl text-transparent bg-clip-text bg-gradient-to-b from-lime-400 to-lime-600"></i><br> |
| 22 | +<span class="text-4xl" v-html="result2"></span> |
| 23 | +</div> |
| 24 | +<div class="flex justify-center items-center"> |
| 25 | + |
| 26 | +<span class="text-4xl" v-html="rawHtml"></span> |
| 27 | + |
| 28 | +</div> |
| 29 | +<div class="text-center"> |
| 30 | +<i class="fa-solid fa-desktop text-5xl text-transparent bg-clip-text bg-gradient-to-b from-amber-400 to-amber-600"></i><br> |
| 31 | +<span class="text-4xl" v-html="result1"></span> |
| 32 | +</div> |
| 33 | + |
| 34 | +</div> |
| 35 | + |
| 36 | +<div class="grid grid-cols-3 p-10 text-4xl mx-auto max-w-lg"> |
| 37 | +<div class="text-center"> |
| 38 | +<label>{{ Player_score }}</label> |
| 39 | +</div> |
| 40 | + |
| 41 | +<div class="text-center "> |
| 42 | + |
| 43 | +</div> |
| 44 | + |
| 45 | +<div class="text-center"> |
| 46 | +<label class="items-center">{{ Comp_score }}</label> |
| 47 | +</div> |
| 48 | +</div> |
| 49 | + |
| 50 | +<div class="grid grid-cols-3 px-10 py-10 mx-auto max-w-lg min-h-[15%]"> |
| 51 | +<div class="text-center"> |
| 52 | + <button v-if="showRock" class="bg-transparent" @click="rand_select(); sel_rock()"> |
| 53 | + <i id="rock" class="rounded fa-solid fa-hill-rockslide text-7xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600 hover:bg-gradient-to-t"></i> |
| 54 | + </button> |
| 55 | +</div> |
| 56 | +<div class="text-center"> |
| 57 | + <button v-if="showPaper" @click="rand_select(); sel_paper()"> |
| 58 | + <i id="pap" class="rounded fa-solid fa-scroll text-7xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600 hover:bg-gradient-to-t"></i> |
| 59 | + </button> |
| 60 | +</div> |
| 61 | +<div class="text-center"> |
| 62 | + <button v-if="showScissors" @click="rand_select(); sel_scissors()"> |
| 63 | + <i id="sci" class="bg-fuchsia-100 rounded fa-solid fa-scissors text-7xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600 hover:bg-gradient-to-t"></i> |
| 64 | + </button> |
| 65 | +</div> |
| 66 | +</div> |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +<div class="flex justify-center mx-auto max-w-lg p-10"> |
| 71 | +<button class="w-12 h-12 bg-fuchsia-400 text-white font-bold shadow-2xl rounded-full" @click="reset_score()"> |
| 72 | +<i class="text-3xl text-fuchsia-800 justify-center fa-solid fa-power-off hover:text-fuchsia-200"></i> |
| 73 | +</button> |
| 74 | +</div> |
| 75 | + |
| 76 | +</div> |
| 77 | +</body> |
| 78 | + |
| 79 | + <script type="module"> |
| 80 | + const app = Vue.createApp({ |
| 81 | + data() { |
| 82 | + return { |
| 83 | + result1: " ", |
| 84 | + result2: ' ', |
| 85 | + output: ' ', |
| 86 | + Comp_score: 0, |
| 87 | + Player_score: 0, |
| 88 | + rawHtml: '', |
| 89 | + showRock: true, |
| 90 | + showPaper: true, |
| 91 | + showScissors: true |
| 92 | + } |
| 93 | + }, |
| 94 | + methods: { |
| 95 | + rand_select() { |
| 96 | + var items = Array("Rock", "Paper", "Scissors") |
| 97 | + var a = Math.floor(Math.random()*items.length) |
| 98 | + var item = items[a]; |
| 99 | + this.result1 = item; |
| 100 | + }, |
| 101 | +// console.log(this.result1, //this.result2,this.output); |
| 102 | + |
| 103 | + sel_rock() { |
| 104 | + this.showRock = false; |
| 105 | + this.result2 = '<i id="rock" class="rounded fa-solid fa-hill-rockslide text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 106 | + if(this.result1=="Paper"){ |
| 107 | + this.output = "Computer Won"; |
| 108 | + this.Comp_score++; |
| 109 | + this.rawHtml = '<i class="fa-solid fa-thumbs-down fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-amber-400 to-amber-600" style="--fa-animation-duration: 2s;"></i>'; |
| 110 | + this.result1='<i id="pap" class="rounded fa-solid fa-scroll text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 111 | + } else if(this.result1=="Scissors"){ |
| 112 | + this.output = "You Won"; |
| 113 | + this.Player_score++; |
| 114 | + |
| 115 | + this.rawHtml = '<i class="fa-solid fa-thumbs-up fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-lime-400 to-lime-600"></i>'; |
| 116 | + this.result1 = '<i id="sci" class="rounded fa-solid fa-scissors text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 117 | + } else { |
| 118 | + this.output = "It's a tie" |
| 119 | + this.rawHtml = '<i class="fa-brands fa-black-tie fa-beat text-transparent bg-clip-text bg-gradient-to-r from-lime-400 to-amber-400" style="--fa-animation-duration: 2s;"></i>'; |
| 120 | + this.result1 = '<i id="sci" class="rounded fa-solid fa-hill-rockslide text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 121 | + } |
| 122 | + setTimeout(() => this.showRock = true, 200); |
| 123 | + }, |
| 124 | + sel_paper() { |
| 125 | + this.showPaper = false; |
| 126 | + this.result2 = '<i id="pap" class="rounded fa-solid fa-scroll text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 127 | + if(this.result1=="Rock"){ |
| 128 | + this.output = "You Won"; |
| 129 | + this.Player_score++; |
| 130 | + this.rawHtml = '<i class="fa-solid fa-thumbs-up fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-lime-400 to-lime-600"></i>'; |
| 131 | + this.result1 = '<i id="rock" class="rounded fa-solid fa-hill-rockslide text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 132 | + } else if(this.result1=="Scissors"){ |
| 133 | + this.output = "Computer Won"; |
| 134 | + this.Comp_score++; |
| 135 | + this.rawHtml = '<i class="fa-solid fa-thumbs-down fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-amber-400 to-amber-600" style="--fa-animation-duration: 2s;"></i>'; |
| 136 | + this.result1 = '<i id="sci" class="rounded fa-solid fa-scissors text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 137 | + } else { |
| 138 | + this.output = "It's a tie" |
| 139 | + this.rawHtml = '<i class="fa-brands fa-black-tie fa-beat text-transparent bg-clip-text bg-gradient-to-r from-lime-400 to-amber-400" style="--fa-animation-duration: 2s;"></i>'; |
| 140 | + this.result1='<i id="pap" class="rounded fa-solid fa-scroll text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 141 | + } |
| 142 | + setTimeout(() => this.showPaper = true, 200); |
| 143 | + }, |
| 144 | + sel_scissors() { |
| 145 | + this.showScissors = false; |
| 146 | + this.result2 = '<i id="pap" class="rounded fa-solid fa-scissors text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 147 | + if(this.result1=="Rock"){ |
| 148 | + this.output = "Computer Won"; |
| 149 | + this.Comp_score++; |
| 150 | + this.rawHtml = '<i class="fa-solid fa-thumbs-down fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-amber-400 to-amber-600" style="--fa-animation-duration: 2s;"></i>'; |
| 151 | + this.result1='<i id="rock" class="rounded fa-solid fa-hill-rockslide text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">' |
| 152 | + } else if(this.result1=="Paper"){ |
| 153 | + this.output = "You Won"; |
| 154 | + this.Player_score++; |
| 155 | + this.rawHtml = '<i class="fa-solid fa-thumbs-up fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-lime-400 to-lime-600"></i>'; |
| 156 | + this.result1='<i id="pap" class="rounded fa-solid fa-scroll text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">' |
| 157 | + } else { |
| 158 | + this.output = "It's a tie"; |
| 159 | + this.rawHtml = '<i class="fa-brands fa-black-tie fa-beat text-transparent bg-clip-text bg-gradient-to-r from-lime-400 to-amber-400" style="--fa-animation-duration: 2s;"></i>'; |
| 160 | + this.result1 = '<i id="sci" class="rounded fa-solid fa-scissors text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'; |
| 161 | + } |
| 162 | + setTimeout(() => this.showScissors = true, 200); |
| 163 | + }, |
| 164 | + reset_score(){ |
| 165 | + this.Comp_score = 0; |
| 166 | + this.Player_score = 0; |
| 167 | + this.result1 = ''; |
| 168 | + this.result2 = ''; |
| 169 | + this.output = ''; |
| 170 | + this.rawHtml = ''; |
| 171 | + }, |
| 172 | + }, |
| 173 | + }) |
| 174 | + |
| 175 | + app.mount('#app') |
| 176 | + </script> |
| 177 | + |
| 178 | +</html> |
0 commit comments