制作老虎机小游戏

一、代码

1.老虎机代码

代码如下(示例):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #b{
            background: url("image/老虎机.jpg.png");
            z-index: -1;
            width: 335px;
            height: 326px;
            position:  absolute;
            margin-top: 200px;
            margin-left: 400px;
        }
        #btn1{

        }
    </style>
</head>
<body>
<div id=>
    <div id="a" style="width: 50px;
            height: 50px;
            border: 2px solid #ff0000;
            position: absolute;
            margin-top: 215px;
            margin-left: 425px;">

    </div>
    <div id="b"></div>
    <div>
        <button id="btn1" onclick="start2()">开始</button>
        <button id="btn2" onclick="stop2()">停止</button>
    </div>
</div>
</body>
<script>
    let a = document.getElementById("a");
    let ii=0;
    let w=425;
    let h=215;
    function start2(){
         ss = setInterval(show,100);
    }

    function stop2() {
        clearInterval(ss)
    }
    function show(){
        ++ii;
        i=ii%21;
        if (i<6) {
            w += 48;
            a.style.marginLeft = w + "px";
        }else if (i<=10){
            h+=49;
            a.style.marginLeft = w + "px";
            a.style.marginTop = h + "px";
        }else if (i<=15){
            w-=48;
            a.style.marginLeft = w + "px";
        }else if (i<=19){
            h-=49;
            a.style.marginTop = h + "px";
        }else if (i==20){
            a.style.marginLeft ="425px";
            a.style.marginTop ="215px";
            w=425;
            h=215;
            ii=0;
        }
    }
</script>
</html>

在这里插入图片描述

总结

以上就是制造老虎机小游戏的全部内容,主要利用的是html、css、以及js的技术实现的老虎机小游戏。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值