Javascript: 迷宫与打地鼠

github地址:小威威的github

1.迷宫

项目要求:

需求规格(50分)
UI(10分):UI与上图完全一致;或者,自由发挥,设计出更加漂亮、合理的UI。
正常赢(10分):移动鼠标,从S开始,到E结束,中间不碰墙,赢得游戏,显示“You Win”
碰墙输(10分):从S开始后,到E结束之前,碰墙,墙变红,输,显示“You Lose”
重置结果(10分):离开迷宫,墙恢复正常;从S开始时,隐藏结果显示
发现作弊(10分):如果用户未经过S,就指到E,又或者指向S之后,从迷宫外绕路指向E,显示”Don’t cheat, you should start form the ‘S’ and move to the ‘E’ inside the maze!”

效果图如下:
Maze

HTML代码如下:

<!DOCTYPE html>
<html>
    <head>
        <title>The Amazing Mouse Maze</title>
        <link rel="stylesheet" type="text/css" href="CSS/maze.css">
        <script type="text/javascript" src="Js/maze.js"></script>
    </head>
    <body>
        <h1>The Amazing Mouse Maze</h1>
        <p>Move your mouse over the "S" to begin.</p>
        <p id="result"><br></p>
        <div id="maze">
            <div id="wall_1" class="wall"></div>
            <div id="wall_2" class="wall"></div>
            <div id="wall_3" class="wall"></div>
            <div id="wall_4" class="wall"></div>
            <div id="wall_5" class="wall"></div>
            <div id="path_1" class="path">
                <div id="start">
                    <p>S</p>
                </div>
            </div>
            <div id="path_2" class="path"></div>
            <div id="path_3" class="path"></div>
            <div id="path_4" class="path"></div>
            <div id="path_5" class="path">
                <div id="end">
                    <p>E</p>
                </div>
                <!--用于测试作弊的结构-->
                <div id="test"></div>
            </div>
        </div>
        <p>The object of this game is to guide the mouse cursor through the start area<br>
           and get to the end area. Be sure to avoid the walls:
        </p>
        <div id="wall_example"></div>
        <br>
        <p>Good luck!</p>
    </body>
</html>

CSS代码如下:

html, body {
    width: 100%;
    height: 100%;
    margin: 0px;
    padding: 0px;
    overflow: hidden;
    text-align: center;
    font-family: "Andale Mono", Arial, sans-serif;
}

.wall, .path {
    display: inline-block;
    position: absolute;
}

body>p:nth-of-type(-n+2) {
    
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值