Git Product home page Git Product logo

flip-coin's People

Contributors

avuku-pragatheswari avatar

Watchers

 avatar

flip-coin's Issues

Flip-a-coin-modification

use this code and u need to seperate those into individual docx-css and js

one isse with this checkguess is not working properly u may rectify it

`

<style> body { font-family: 'Arial', sans-serif; background-color: #f5f5f5; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; }
    #coin {
        width: 150px;
        height: 150px;
        position: relative;
        perspective: 1000px;
        cursor: pointer;
        transition: transform 1s;
    }

    .side {
        width: 100%;
        height: 100%;
        position: absolute;
        backface-visibility: hidden;
        border-radius: 10px;
    }

    .side-hidden {
        visibility: hidden;
    }

    .side-visible {
        visibility: visible;
    }

    #guess {
        margin-top: 20px;
        padding: 8px;
        font-size: 16px;
    }

    button {
        margin-top: 10px;
        padding: 10px 20px;
        font-size: 18px;
        background-color: #4caf50;
        color: #fff;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        transition: background-color 0.3s;
    }

    button:hover {
        background-color: #45a049;
    }
</style>
<title>Coin Flip Game</title>
Heads Tails

Choose your guess:
Heads Tails

Check Guess
Flip Coin

<script> function flipCoin() { const coin = document.getElementById('coin'); const outcome = Math.random() < 0.5 ? 'heads' : 'tails'; coin.style.transform = 'rotateY(1800deg)'; // Rotate the coin setTimeout(() => { coin.innerHTML = ''; // Clear the content coin.classList.remove('heads', 'tails'); coin.style.transform = 'rotateY(0deg)'; // Reset rotation void coin.offsetWidth; // Trigger reflow to restart the animation // Add the new image after the flip const newImage = document.createElement('img'); newImage.src = outcome === 'heads' ? 'images/head.png' : 'images/tail.png'; newImage.alt = outcome.charAt(0).toUpperCase() + outcome.slice(1); // Capitalize first letter newImage.classList.add('side', `side-${outcome}`); coin.appendChild(newImage); }, 1000); // Adjust the duration to match the CSS animation duration } function checkGuess() { const coin = document.getElementById('coin'); const guess = document.getElementById('guess').value; // Check if a guess has been made if (!guess) { alert('Please make a guess before checking.'); return; } // Remove the previous visibility classes from both sides coin.querySelector('.side-heads').classList.remove('side-visible'); coin.querySelector('.side-tails').classList.remove('side-visible'); coin.querySelector('.side-heads').classList.add('side-hidden'); coin.querySelector('.side-tails').classList.add('side-hidden'); if (coin.classList.contains(`side-${guess}`)) { // If the guess is correct, update the visible side coin.querySelector(`.side-${guess}`).classList.remove('side-hidden'); coin.querySelector(`.side-${guess}`).classList.add('side-visible'); alert('Your guess is correct!'); } else { alert('Sorry, your guess is incorrect. Try again!'); } } </script> `

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.