飞机

来源:互联网 发布:就知武松打虎有多扯了 编辑:程序博客网 时间:2024/04/20 15:01
<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title>    <style type="text/css">        #timor{width: 300px;height: 600px;background-color: black;}        label{position: absolute;}        .img{            position: absolute;            top: 200px;            left: 600px;        }        .score{            position: absolute;            top: 10px;            left: 700px;            background-color:black;            color: white;        }    </style>    <script type="text/javascript" src="JS/jquery-1.11.1.js"></script>    <script type="text/javascript" src="JS/enemyAirPlane.js"></script>    <script type="text/javascript" src="JS/bullets.js"></script>    <script type="text/javascript" src="JS/teammateAirPlane.js"></script>    <script type="text/javascript">        var isGameOver = true;//是否触发游戏结束的标识        var score = 0;// 游戏的得分        //窗口加载事件        $(function(){//记录成绩的div            var label = $("<div><span id='score'></span><span id='no'></span></div>");//定义一个div放lalbel            label.addClass("score");//lalbel名字score            $("body").append(label);//把记录成绩的lalbel放入body            $("#score").text("分数");//HTML页面显示'分数'            $("#no").text(score);            gameBegin();//运行的入口        });        //游戏运行的入口,检测游戏是否可以开始        function gameBegin(){            if(isGameOver){                var img = $("<div><img src='image/4.png'></div>");//在游戏界面首先放置一张图片按钮,用来启动游戏                $("body").append(img);//添加到body里                img.addClass("img");//类名img                img.click(function(){//为图片写点击事件                    score = 0;//初始化分数为0                    $("#no").text(score);                    isGameOver = false;//将判断是否碰撞赋值为false                    img.remove();//点击后清除图片                    gameStart();//运行游戏                });            }        }        function gameStart(){//如果游戏的标识为ture,则运行游戏            if(!isGameOver){                setInterval(createNewPlane,2000);//每两秒钟出现一个敌机                myAirplaneControling();//调用我方飞机运行            }        }        //创建子弹对象并实现子弹事件        function butCreating(){            var newBut = new Bullets();            newBut.Direction();            newBut.riseup();        }        //创建敌方飞机,并实现敌机运动事件        function createNewPlane(){            if(!isGameOver) {                var newPlane = new Plane();                newPlane.setPosition();                newPlane.process();            }        }    </script></head><body><div align="center">    <div id="timor"></div></div></body></html>

0 0
原创粉丝点击