jquery实现鼠标跟随挡板弹跳球小游戏效果代码

代码语言:html

所属分类:游戏

代码描述:jquery实现鼠标跟随挡板弹跳球小游戏效果代码

代码标签: 跟随 挡板 弹跳 小游戏 效果

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

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>弹跳球</title>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>

    <style>
        html,body {
            margin: 0;
            cursor: none;
            background-color: #212121;
        }
        .ball,.tail {
            position: fixed;
            border-radius: 100%;
        }
        .paddle {
            position: fixed;
            bottom: 12%;
            border: 2px solid white;
            border-radius: 8px;
            z-index: 100;
        }
        .block {
            float: left;
            box-shadow: inset 0 0 0 1px black,inset 0 0 0 2px white;
            border-radius: 2px;
            width: 10%;
            height: 20px;
            color: white;
        }
        .wave {
            animation: wave .5s 1;
        }
        /* ANIMATIONS */
@keyframes wave {
            0% {
                box-shadow: 0 0 0 0 transparent;
            }
            15% {
                box-shadow: 0 0 0 10px;
                background: transparent;
            }
            100% {
                box-shadow: 0 0 0 20px transparent;
            }
        }

@keyframes floatOne {
            0% {
                opacity: 1;
            }
            50% {
                opacity: 1;
                background: transparent;
            }
            100% {
                opacity: 0;
                transform: translate3D(0,-20px,0) scale(.2);
            }
        }

@keyframes floatTwo {
            0% {
                opacity: 1;
            }
            50% {
                opacity: 1;
                background: transparent;
            }
            100% {
                opacity: 0;
                transform: translate3D(0,-35px,0) scale(.1);
            }
        }

@keyframes floatThree {
            0% {
                opacity: 1;
            }
            50% {
                opacity: 1;
                background: transparent;
            }
            100% {
                opacity: 0;
                transform: translate3D(0,-50px,0) scale(.3);
            }
        }

@keyframes floatFour {
            0% {
                opacity: 1;
            }
            50% {
                opacity: 1;
                background: transparent;
            }
            100% {
                opacity: 0;
                transform: translate3D(0,-65px,0) scale(.1);
            }
        }

@keyframes floatFive {
            0% {
                opacity: 1;
            }
            50% {
                opacity: 1;
                background: transparent;
            }
            100% {
                opacity: 0;
                transform: translate3D(0,-80px,0) scale(.2);
            }
        }
    </style>
</head>
<body>

    <div></div>

    <script>
        var blocks = 10;
        var paddleWidth = 125;
        var paddleHeight = 8;
        var ballSize = 28;
        var speed = 3;

        /*for (i=1;i<=blocks;i++) {
  $('body').append('<div class="block"></div>');
}*/

        $('body').append('<div class="ball" style="width:'+ballSize+'px;height:'+ballSize+'px;"></div><div class="paddle" style="width:'+paddleWidth+'px;height:'+paddleHeight+'px;"></div>');

        /* CHANGE HUE */
        setInterval(function() {
            $('.ball').css('background', 'hsla('+H+',100%,70%,1)');
        }, 40);
        var H = 0;
        setInterval(function() {
            if (H <= 360) {
                H++;
            } else {
                H = 0;
            }
        }, 20);

        /* PADDLE INTERACTION */
        $(document).bind('mouseenter touchstart', function(e) {
     .........完整代码请登录后点击上方下载按钮下载查看

网友评论0