김묭의 자기개발

제비뽑기 게임 본문

코딩/내가 만든 코딩

제비뽑기 게임

포령 2022. 12. 15. 04:00

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link href="../minesweeper/css/bootstrap.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
        integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
        crossorigin="anonymous"></script>

    <title>스파르타코딩클럽 | 부트스트랩 연습하기</title>
    <style>
        .game {
            color: white;
            margin: 500px;
            margin-left: 500px;

        }

        .setting {
            margin: 50px;
        }

        .gamebox>button {
            margin: 10px;
            width: 100px;
            height: 100px;
            border-radius: 20%;
            font-size: xx-large;
        }

        .setting>button {
            background-color: beige;
            margin: 38px;
            width: 100px;
            height: 100px;
            border-radius: 20%;
            font-size: xx-large;
        }

        .reset>button {
            background-color: brown;
            margin: 38px;
            width: 100px;
            height: 100px;
            border-radius: 100%;
            font-size: xx-large;
        }
    </style>
    <script>
    </script>
</head>

<body>
    <div class="game">
        <div class="setting">
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse"
                data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
                aria-label="Toggle navigation"><span class="navbar-toggler-icon">0</button>
            <button class="">🚩</button>
            <button>💣</button>

        </div>

        <div class="gamebox">
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <br>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <br>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <br>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <br>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <button onclick="hey(this)">o</button>
            <br>
        </div>

        <div class="reset">
            <button onclick="window.location.reload()">reset</button>
        </div>
        <button id='gametext' visibility : visible onclick="hide(this)">게임이 끝났습니다.</button>
    </div>
</body>
<script>
    function hey(btnElement) {
        let arr1 = ["당첨","","","",""]
       
        btnElement.value = arr1[Math.floor(Math.random()*5)];
        btnElement.innerText = btnElement.value;
        btnElement.className = "reset";
        if (btnElement.innerText == "당첨") {
            alert("니가 이겼습니다!");
            document.getElementById('gametext').style.visibility= 'visible';
        }
    }
    function hide(val){
        val.style.visibility = 'hidden';
    }
</script>

</html>