three打造一个控制赛车不相撞的游戏代码

代码语言:html

所属分类:游戏

代码描述:three打造一个控制赛车不相撞的游戏代码,按住键盘向上箭头开始,向下箭头减速,R键重新开始

代码标签: 控制 赛车 相撞 游戏

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<html lang="en">
<head>

    <meta charset="UTF-8">





    <style>
@import url("https://fonts.googleapis.com/css?family=Press+Start+2P");

        body {
            margin: 0;
            color: white;
            font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
        }

        button {
            outline: none;
            cursor: pointer;
            border: none;
            box-shadow: 3px 5px 0px 0px rgba(0, 0, 0, 0.75);
        }

        a,
        a:visited {
            color: inherit;
        }

        #score {
            position: absolute;
            font-family: "Press Start 2P", cursive;
            font-size: 0.9em;
            color: white;
            transform: translate(-50%, -50%);
            opacity: 0.9;
            max-width: 100px;
            text-align: center;
            line-height: 1.6em;
        }

        #controls {
            position: absolute;
            bottom: 50px;
            left: 50px;
            display: none;
        }

        #controls #buttons {
            width: 80px;
            opacity: 0;
            transition: opacity 2s;
        }

        #controls #instructions {
            margin-left: 20px;
            max-width: 300px;
            background-color: rgba(0, 0, 0, 0.2);
            padding: 20px;
            opacity: 0;
            transition: opacity 2s;
        }

        #controls button {
            width: 100%;
            height: 40px;
            background-color: white;
            border: 1px solid black;
            margin-bottom: 10px;
        }

        #results {
            position: absolute;
            align-items: center;
            justify-content: center;
            height: 100%;
            width: 100%;
            background-color: rgba(20, 20, 20, 0.75);
            display: none;
            z-index: 51;
        }

        #results .content {
            max-width: 350px;
            padding: 50px;
            border-radius: 20px;
        }

        #result-youtube {
            display: flex;
            background-color: white;
            padding: 20px;
            color: black;
            text-decoration: none;
            cursor: pointer;
        }

        #result-youtube span {
            margin-top: 5px;
            margin-left: 20px;
        }

        .youtube,
        #youtube-card {
            display: none;
            color: black;
        }

        #youtube-main {
            opacity: 0;
            transition: opacity 2s;
        }

@media (min-height: 425px) {
            #score {
                font-size: 1.5em;
                max-width: 150px;
            }

            #controls {
                display: flex;
            }

    </style>



</head>

<body >
    <div id="score" style="left: 212.711px; top: 329.5px;">
        Press UP
    </div>

    <div id="controls">
        <div id="buttons" style="opacity: 1;">
            <button id="accelerate">
                <svg width="30" height="30" viewBox="0 0 10 10">
                    <g transform="rotate(0, 5,5)">
                        <path d="M5,4 L7,6 L3,6 L5,4"></path>
                    </g>
                </svg>
            </button>
            <button id="decelerate">
                <svg width="30" height="30" viewBox="0 0 10 10">
                    <g transform="rotate(180, 5,5)">
                        <path d="M5,4 L7,6 L3,6 L5,4"></path>
                    </g>
                </svg>
            </button>
        </div>
        <div id="instructions" style="opacity: 1;">
            Press UP to start. Avoid collision with other vehicles by accelerating
            or decelerating with the UP and DOWN keys.
        </div>
    </div>

    <div id="results" style="display: none;">
        <div class="content">
            <h1>You hit another vehicle</h1>
            <p>
                To reset the.........完整代码请登录后点击上方下载按钮下载查看

网友评论0