From 7e89d45abcba9f0622dcf0eeb8f57e3ca58adced Mon Sep 17 00:00:00 2001 From: MrEidam Date: Sun, 11 Aug 2024 00:25:56 +0200 Subject: [PATCH] Dice war 0.3 --- Games/DiceWar/Dices/0.png | Bin 0 -> 136 bytes Games/DiceWar/Dices/1.png | Bin 0 -> 145 bytes Games/DiceWar/Dices/2.png | Bin 0 -> 148 bytes Games/DiceWar/Dices/3.png | Bin 0 -> 146 bytes Games/DiceWar/Dices/4.png | Bin 0 -> 149 bytes Games/DiceWar/Dices/5.png | Bin 0 -> 156 bytes Games/DiceWar/Dices/6.png | Bin 0 -> 149 bytes Games/DiceWar/Dices/7.png | Bin 0 -> 158 bytes Games/DiceWar/index.html | 41 ++++++++++++++++++++++ Games/DiceWar/main.js | 70 ++++++++++++++++++++++++++++++++++++++ Games/DiceWar/style.css | 56 ++++++++++++++++++++++++++++++ Games/index.html | 1 + 12 files changed, 168 insertions(+) create mode 100644 Games/DiceWar/Dices/0.png create mode 100644 Games/DiceWar/Dices/1.png create mode 100644 Games/DiceWar/Dices/2.png create mode 100644 Games/DiceWar/Dices/3.png create mode 100644 Games/DiceWar/Dices/4.png create mode 100644 Games/DiceWar/Dices/5.png create mode 100644 Games/DiceWar/Dices/6.png create mode 100644 Games/DiceWar/Dices/7.png create mode 100644 Games/DiceWar/index.html create mode 100644 Games/DiceWar/main.js create mode 100644 Games/DiceWar/style.css diff --git a/Games/DiceWar/Dices/0.png b/Games/DiceWar/Dices/0.png new file mode 100644 index 0000000000000000000000000000000000000000..6b15753adfd76489ce2388a272deaf8496413999 GIT binary patch literal 136 zcmeAS@N?(olHy`uVBq!ia0vp^k|4~&3?$8t&j1AIbU|NsBL{D|}kAeXbiBeIx*f$uN~Gak=hkpdLt^K@|x(Kw$h!D_gTe~DWM4fZ}TK{ literal 0 HcmV?d00001 diff --git a/Games/DiceWar/Dices/4.png b/Games/DiceWar/Dices/4.png new file mode 100644 index 0000000000000000000000000000000000000000..cd06bc05f7f527d28c87f611fd105b522b8dc31d GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^k|4~&3?$8t&j6bo2P$UpboFyt=akR{0DXul)c^nh literal 0 HcmV?d00001 diff --git a/Games/DiceWar/index.html b/Games/DiceWar/index.html new file mode 100644 index 0000000..a5d1360 --- /dev/null +++ b/Games/DiceWar/index.html @@ -0,0 +1,41 @@ + + + + + + + + + + Dice War + + +
+
+
+ Enemy Dice + Enemy Dice + Enemy Dice + Enemy Dice + Enemy Dice +
+

Enemy score: 0

+
+
+

Your score: 0

+
+ Player Dice + Player Dice + Player Dice + Player Dice + Player Dice +
+
+

Do you think that you have score then the Enemy?

+ +
+
+
+ + + \ No newline at end of file diff --git a/Games/DiceWar/main.js b/Games/DiceWar/main.js new file mode 100644 index 0000000..fb9fe3d --- /dev/null +++ b/Games/DiceWar/main.js @@ -0,0 +1,70 @@ +let enemy = [ + document.querySelector('#enDice1'), + document.querySelector('#enDice2'), + document.querySelector('#enDice3'), + document.querySelector('#enDice4'), + document.querySelector('#enDice5'), +]; +let player = [ + document.querySelector('#plDice1'), + document.querySelector('#plDice2'), + document.querySelector('#plDice3'), + document.querySelector('#plDice4'), + document.querySelector('#plDice5'), +]; +let enScore = document.querySelector('#enemyScore'); +let plaScore = document.querySelector('#playerScore'); + +let enemyScore = 0; +let playerScore = 0; + +function ranD6(){ + return Math.floor(Math.random()*6)+1; +} + +function enemyRoll(){ + enemyScore = 0; + enemy.forEach(e => { + const point = ranD6(); + enemyScore += point; + e.src = `./Dices/${point}.png`; + e.classList.value=""; + e.classList.add("pop"); + setTimeout(() => { + e.classList.remove('pop'); + },500); + }); + enScore.innerHTML = enemyScore; +} + +function playerRoll(){ + playerScore = 0; + + player.forEach(e => { + const point = ranD6(); + playerScore += point; + e.src = `./Dices/${point}.png`; + e.classList.value=""; + e.classList.add("pop"); + setTimeout(() => { + e.classList.remove('pop'); + },500); + }); + plaScore.innerHTML = playerScore; +} + +function gamble(){ + enemyRoll(); + playerRoll(); + setTimeout(() => { + if(playerScore>enemyScore){ + alert('You won!'); + }else if(playerScore2048 RockPaperScissors QuessNumber-1D6 + DiceWar \ No newline at end of file