<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><style>body{background-image: url("zombies/bg1.jpg");overflow: hidden;}img{position: absolute;width: 100px;height: 100px;}</style>
</head>
<body>
<h3 id="s_h3">成功数量:0</h3>
<h3 id="f_h3">失败数量:0</h3>
<script src="../js/jquery-1.4.2.js"></script>
<script>let sCount=0;let fCount=0;
</script>
<script>let w=$(window).width();let h=$(window).height();$("body").css("background-size",w+"px"+h+"px");onresize=function () {w=$(window).width();h=$(window).height();$("body").css("background-size",w+"px"+h+"px");}setInterval(function () {let type=parseInt(sCount/20);if (type>3){type=3;}let hp=type+1;let img=$("<img src='zombies/zomb"+type+".png'>");img.attr("hp",hp)let top=parseInt(Math.random()*(h-50));img.css({"left":w+"px","top":top+"px"})$("body").append(img)img.mouseover(function () {let hp=img.attr("hp");hp--;img.attr("hp",hp)if (hp<=0){img.remove();sCount++;$("#s_h3").text("成功数量:"+sCount);}})},1)setInterval(function () {$("img").each(function () {let left=parseInt($(this).css("left"));left-=1;$(this).css("left",left+"px");if (left<=50){$(this).remove();fCount++;$("#f_h3").text("失败数量:"+fCount);if (fCount>=10){setTimeout(function () {alert("游戏结束了!")location.reload();},50);}}})},10)