Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Bookmarklet Code To Play RPS

This post has nothing to do with unity code, I just wanted to share some code I made in other coding languages

  • Right click on bookmarks bar and click add page.
  • Click on more or add folder.
  • Copy the code below and paste it in the URL section.
  • Name it whatever you want.
  • Go to any page and click that bookmark.
  • Have fun playing rock paper scissors.

- the formatting of the text on screen from the code might be a little buggy

ALL CODE WAS MADE BY ANICREATIONS

    javascript:function random(min, max) {     return Math.floor(Math.random() * (max - min + 1)) + min; }; var x = 0; var rockSet = false; var paperSet = false; var sciSet = false; var rock = document.createElement('button');     rock.style.color = 'yellow';     rock.textContent = 'Rock';     rock.style.fontSize = '50px';     rock.style.width = '200px';     rock.style.height = '200px';     rock.style.borderRadius = '50%';     rock.style.position = "fixed";     rock.style.top = '30%';     rock.style.left = '5%';     rock.style.zIndex = '9998';     rock.style.opacity = '60%';     rock.id = 'rock';     rock.style.backgroundColor = 'blue';     document.body.appendChild(rock); var paper = document.createElement('button');     paper.style.color = 'yellow';     paper.textContent = 'Paper';     paper.style.fontSize = '50px';     paper.style.width = '200px';     paper.style.height = '200px';     paper.style.borderRadius = '50%';     paper.style.position = "fixed";     paper.style.top = '30%';     paper.style.left = '30%';     paper.id = 'paper';     paper.style.backgroundColor = 'blue';     paper.style.zIndex = '9998';     paper.style.opacity = '60%';     document.body.appendChild(paper); var scizzor = document.createElement('button');     scizzor.style.color = 'yellow';     scizzor.textContent = 'Scissor';     scizzor.style.fontSize = '50px';     scizzor.style.width = '200px';     scizzor.style.height = '200px';     scizzor.style.borderRadius = '50%';     scizzor.style.position = "fixed";     scizzor.style.top = '30%';     scizzor.style.left = '55%';     scizzor.id = 'sci';     scizzor.style.backgroundColor = 'blue';     scizzor.style.opacity = '60%';     scizzor.style.zIndex = '9998';     document.body.appendChild(scizzor); var shoot = document.createElement('button');     shoot.textContent = 'Shoot';     shoot.style.fontSize = '75px';     shoot.style.backgroundColor = 'blue';     shoot.style.color = 'yellow';     shoot.style.position = 'fixed';     shoot.style.top = '70%';     shoot.style.left = '30%';     shoot.id = 'shoot';     shoot.style.borderRadius = '10%';     document.body.appendChild(shoot); var score = document.createElement('h1');     score.textContent = '';     score.style.position = 'fixed';     score.style.left = '25%';     score.style.fontSize = '100px';     score.style.top = '57%';     document.body.appendChild(score); var numscore = document.createElement('h1');     numscore.textContent = '0';     numscore.style.fontSize = '100px';     numscore.style.position = 'fixed';     numscore.style.left = '50%';     numscore.style.top = '5%';     document.body.appendChild(numscore); document.getElementById('rock').addEventListener('click', function() {     rockSet = true;     paper.disabled = true;     sci.disabled = true; }); document.getElementById('sci').addEventListener('click', function() {     sciSet = true;     paper.disabled = true;     rock.disabled = true; }); document.getElementById('paper').addEventListener('click', function() {     paperSet = true;     rock.disabled = true;     sci.disabled = true; }); document.getElementById('shoot').addEventListener('click', function() {     var num = random(1, 3);     shoot.style.backgroundColor = 'yellow';     var interval = setInterval (function() {shoot.style.backgroundColor = 'blue';    clearInterval(interval);}, 50);     if (num == 1)     {             if (rockSet)         {             score.textContent = 'Tie';             rockSet = false;             paper.disabled = false;             sci.disabled = false;         }         if (paperSet)         {             score.textContent = 'You Win';             paperSet = false;             rock.disabled = false;             sci.disabled = false;             x = x + 1;             numscore.textContent = x;         }         if (sciSet)         {             score.textContent = 'You Lose';             sciSet = false;             paper.disabled = false;             rock.disabled = false;             if (numscore.textContent !== '0')             {                 x = x - 1;                 numscore.textContent = x;             }         }             }     if (num == 2)     {             if (rockSet)         {             score.textContent = 'You Lose';             rockSet = false;             paper.disabled = false;             sci.disabled = false;             if (numscore.textContent !== '0')             {                 x = x - 1;                 numscore.textContent = x;             }         }         if (paperSet)         {             score.textContent = 'Tie';             paperSet = false;             rock.disabled = false;             sci.disabled = false;         }         if (sciSet)         {             score.textContent = 'You Win';             sciSet = false;             paper.disabled = false;             rock.disabled = false;             x = x + 1;             numscore.textContent = x;         }             }     if (num == 3)     {             if (rockSet)         {             score.textContent = 'You Win';             rockSet = false;             paper.disabled = false;             sci.disabled = false;             x = x + 1;             numscore.textContent = x;         }         if (paperSet)         {             score.textContent = 'You Lose';             paperSet = false;             rock.disabled = false;             sci.disabled = false;             if (numscore.textContent !== '0')             {                 x = x - 1;                 numscore.textContent = x;             }         }         if (sciSet)         {             score.textContent = 'Tie';             sciSet = false;             paper.disabled = false;             rock.disabled = false;         }             }      });

Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.

Please tell me if you have any feedback