JavaScript Canvasに基づく植物大戦ゾンビ、週末爆肝作----------------------------(下)


前のソースコードに続く
クリックして前編にジャンプhttps://blog.csdn.net/weixin_44070254/article/details/115972451?spm=1001.2014.3001.5501

       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="27">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//     ,        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="28">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(z.imageKey>=(that.zombiesEatCount+z.key)){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="29">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				z.imageKey=z.key;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="30">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="31">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			z.image = that.imgObj[z.imageKey];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="32">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="33">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			p.blood--;
         <span class="hljs-comment">//       span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="34">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(p.blood<=
         <span class="hljs-number">0span>){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="35">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-comment">//console.log('     ');span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="36">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				clearInterval(z.timmer);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="37">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="38">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">thisspan>.delPlant(p);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="39">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				zomble.state=
         <span class="hljs-string">'run'span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="40">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				zomble.imageKey=zomble.key=
         <span class="hljs-keyword">thisspan>.count+
         <span class="hljs-number">1span>;
         <span class="hljs-comment">//  keyspan>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="41">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="42">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				z.run();
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="43">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="44">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="45">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	}
        div>
       div>li>
     ol>code>
    <div class="hljs-button {2}" data-title="  " data-report-click="{
      "spm":"1001.2101.3001.4259"}" onclick="hljs.copyCode(event)">div>pre> 
   <h3><a name="t16">a><a name="t16">a>    h3> 
   <pre><code class="hljs typescript">
     <ol class="hljs-ln">
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="1">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         <span class="hljs-comment">//     span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="2">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	Plants.prototype.delPlant=
         <span class="hljs-function"><span class="hljs-keyword">functionspan>(<span class="hljs-params">plant,<span class="hljs-keyword">typespan>span>)span>{
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="3">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!
         <span class="hljs-keyword">typespan>){
         <span class="hljs-comment">//                  span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="4">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//         span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="5">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-built_in">clearIntervalspan>(plant.timmerSelf);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="6">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//           span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="7">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-built_in">clearIntervalspan>(plant.timmer);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="8">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="9">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//     span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="10">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-built_in">thisspan>.clear(plant);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="11">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//plants     span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="12">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-built_in">thisspan>.clearAssign(
         <span class="hljs-built_in">thisspan>.plants,plant);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="13">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//         span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="14">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(plant.bgRect){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="15">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			plant.bgRect.alive=
         <span class="hljs-literal">falsespan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="16">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			plant.bgRect.plant=
         <span class="hljs-literal">falsespan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="17">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="18">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant=
         <span class="hljs-literal">nullspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="19">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	}
        div>
       div>li>
     ol>code>
    <div class="hljs-button {2}" data-title="  " data-report-click="{
      "spm":"1001.2101.3001.4259"}" onclick="hljs.copyCode(event)">div>pre> 
   <h2><a name="t17">a><a name="t17">a>     h2> 
   <p><strong>1、        ,             ,         (         )strong>p> 
   <p><strong>2、   alive   ,          ,     ,      。strong>p> 
   <p><strong>3、      、        、           。strong>p> 
   <pre><code class="hljs kotlin">
     <ol class="hljs-ln" style="width:1121px">
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="1">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">	
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="2">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	Plants.prototype.createSunPlant=function(pos,item){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="3">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> image,plant,sx=
         <span class="hljs-number">0span>,sy=
         <span class="hljs-number">0span>,sWidth=
         <span class="hljs-number">63span>,sHeight=
         <span class="hljs-number">73span>,dx=
         <span class="hljs-number">110span>,dy=
         <span class="hljs-number">300span>,dWidth=
         <span class="hljs-number">63span>,dHeight=
         <span class="hljs-number">73span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="4">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		dx = pos.x,dy=pos.y;
         <span class="hljs-comment">//            span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="5">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="6">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> startKey=
         <span class="hljs-keyword">thisspan>.count+
         <span class="hljs-keyword">thisspan>.zombiesRunCount+
         <span class="hljs-keyword">thisspan>.wandousRunCount+
         <span class="hljs-keyword">thisspan>.zombiesDeadCount+
         <span class="hljs-keyword">thisspan>.sunRunCount+
         <span class="hljs-keyword">thisspan>.zombiesEatCount+
         <span class="hljs-number">1span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="7">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//     span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="8">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		image = 
         <span class="hljs-keyword">thisspan>.imgObj[startKey];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="9">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant = new _.ImageDraw({image:image,sx:sx,sy:sy,sWidth:sWidth,sHeight:sHeight, dx:dx, dy:dy ,dWidth:dWidth,dHeight:dHeight});
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="10">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant.imageKey=startKey;
         <span class="hljs-comment">//         span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="11">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant.key=startKey;
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="12">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant.sunCost=item.sunCost;
         <span class="hljs-comment">//     span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="13">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant.blood=
         <span class="hljs-number">50span>;
         <span class="hljs-comment">//   50  ,   5   ,  100       span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="14">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant.id=
         <span class="hljs-string">'SunPlant'span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="15">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">thisspan>.renderArr2.push(plant);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="16">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="17">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">thisspan>.plants.push(plant);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="18">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">thisspan>.currPlant=plant;
         <span class="hljs-comment">//         span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="19">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="20">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant.alive=alive.bind(
         <span class="hljs-keyword">thisspan>);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="21">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="22">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		function alive(bgRect){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="23">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="24">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			plant.bgRect=bgRect;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="25">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="26">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">thisspan>.sunTotalCount-=plant.sunCost;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="27">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//          span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="28">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">thisspan>.updateCardUse();
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="29">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="30">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">thisspan>.sunCountObj.text=
         <span class="hljs-keyword">thisspan>.sunTotalCount;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="31">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">// 6       span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="32">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			plant.timmer = setInterval(shoot.bind(
         <span class="hljs-keyword">thisspan>),
         <span class="hljs-number">6000span>);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="33">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">thisspan>.plantMusic.play();
         <span class="hljs-comment">//  span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="34">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="35">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="36">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		function shoot(){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="37">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">thisspan>.createSun(plant);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="38">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="39">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//       span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="40">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		plant.timmerSelf = setInterval(animate.bind(
         <span class="hljs-keyword">thisspan>,plant),
         <span class="hljs-number">100span>);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="41">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		function animate(p){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="42">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">varspan> that=
         <span class="hljs-keyword">thisspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="43">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			p.imageKey ++;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="44">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//     ,        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="45">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(p.imageKey>=(that.sunPlantRunCount+p.key)){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="46">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				p.imageKey=p.key;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="47">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="48">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			p.image = that.imgObj[p.imageKey];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="49">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="50">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	}
        div>
       div>li>
     ol>code>
    <div class="hljs-button {2}" data-title="  " data-report-click="{
      "spm":"1001.2101.3001.4259"}" onclick="hljs.copyCode(event)">div>pre> 
   <p><strong>         ,          ,         ,           ,         。strong>p> 
   <p><img alt="" height="238" src="https://img-blog.csdnimg.cn/20210419215313959.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2RrbTEyMzQ1Ng==,size_16,color_FFFFFF,t_70" width="317" />p> 
   <h2><a name="t18">a><a name="t18">a>      h2> 
   <p><strong>1、          ,               ,           ,       。strong>p> 
   <p><strong>2、        、         ,            、      、       、      ,         ,    。strong>p> 
   <h3><a name="t19">a><a name="t19">a>  h3> 
   <pre><code class="hljs javascript">
     <ol class="hljs-ln" style="width:1136px">
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="1">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="2">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	Plants.prototype.createWandou=
         <span class="hljs-function"><span class="hljs-keyword">functionspan>(<span class="hljs-params">plantspan>)span>{
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="3">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> image,img,sx=
         <span class="hljs-number">0span>,sy=
         <span class="hljs-number">0span>,sWidth=
         <span class="hljs-number">28span>,sHeight=
         <span class="hljs-number">28span>,dx=plant.dx+
         <span class="hljs-number">50span>,dy=plant.dy,dWidth=
         <span class="hljs-number">28span>,dHeight=
         <span class="hljs-number">28span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="4">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="5">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> startKey=
         <span class="hljs-number">6span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="6">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//     span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="7">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		image = 
         <span class="hljs-built_in">thisspan>.imgObj[startKey];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="8">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> wandou= 
         <span class="hljs-keyword">newspan> _.ImageDraw({
         <span class="hljs-attr">imagespan>:image,
         <span class="hljs-attr">sxspan>:sx,
         <span class="hljs-attr">syspan>:sy,
         <span class="hljs-attr">sWidthspan>:sWidth,
         <span class="hljs-attr">sHeightspan>:sHeight, 
         <span class="hljs-attr">dxspan>:dx, 
         <span class="hljs-attr">dyspan>:dy ,
         <span class="hljs-attr">dWidthspan>:dWidth,
         <span class="hljs-attr">dHeightspan>:dHeight});
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="9">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-built_in">thisspan>.renderArr2.push(wandou);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="10">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="11">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		wandou.index=plant.index;
         <span class="hljs-comment">//         span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="12">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="13">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-built_in">thisspan>.shootMusic.play();
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="14">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		wandou.timmer = 
         <span class="hljs-built_in">setIntervalspan>(wandouMove.bind(
         <span class="hljs-built_in">thisspan>,wandou),
         <span class="hljs-number">100span>);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="15">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line"> 
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="16">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-function"><span class="hljs-keyword">functionspan> <span class="hljs-title">wandouMovespan>(<span class="hljs-params">wandouspan>)span>{
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="17">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			wandou.dx+=
         <span class="hljs-number">10span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="18">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="19">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">varspan> flag = 
         <span class="hljs-built_in">thisspan>.hit(wandou);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="20">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(flag || wandou.dx>
         <span class="hljs-number">850span>){
         <span class="hljs-comment">//            span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="21">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-built_in">clearIntervalspan>(wandou.timmer);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="22">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">ifspan>(flag){
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="23">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-comment">//         span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="24">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-built_in">thisspan>.hitAnimate(wandou);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="25">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-built_in">thisspan>.hitMusic.play();
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="26">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="27">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="28">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-built_in">thisspan>.clear(wandou);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="29">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				wandou=
         <span class="hljs-literal">nullspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="30">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="31">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="32">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	}
        div>
       div>li>
     ol>code>
    <div class="hljs-button {2}" data-title="  " data-report-click="{
      "spm":"1001.2101.3001.4259"}" onclick="hljs.copyCode(event)">div>pre> 
   <h3><a name="t20">a><a name="t20">a>    h3> 
   <pre><code class="hljs kotlin">
     <ol class="hljs-ln" style="width:956px">
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="1">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         <span class="hljs-comment">//  span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="2">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	Plants.prototype.hit=function(obj){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="3">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> arr = 
         <span class="hljs-keyword">thisspan>.zombies;
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="4">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">forspan>(
         <span class="hljs-keyword">varspan> i=
         <span class="hljs-number">0span>;i<arr.length;i++){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="5">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">varspan> item = arr[i];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="6">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(item.dx<=obj.dx+obj.dWidth && obj.index==item.index ){
         <span class="hljs-comment">//                   span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="7">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				item.blood--;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="8">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">ifspan>(item.blood==
         <span class="hljs-number">0span>){
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="9">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					clearInterval(item.timmer);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="10">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">ifspan>(item.state==
         <span class="hljs-string">'run'span>){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="11">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						item.imageKey=item.key=item.key+
         <span class="hljs-keyword">thisspan>.zombiesRunCount+
         <span class="hljs-keyword">thisspan>.wandousRunCount;
         <span class="hljs-comment">//        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="12">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					}
         <span class="hljs-keyword">elsespan> 
         <span class="hljs-keyword">ifspan>(item.state==
         <span class="hljs-string">'eat'span>){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="13">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						item.imageKey=item.key=item.key-
         <span class="hljs-keyword">thisspan>.sunRunCount-
         <span class="hljs-keyword">thisspan>.zombiesDeadCount;
         <span class="hljs-comment">//        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="14">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="15">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="16">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					item.state=
         <span class="hljs-string">'dead'span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="17">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">thisspan>.addCount();
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="18">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">thisspan>.dead(item);
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="19">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					arr.splice(i,
         <span class="hljs-number">1span>);
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="20">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="21">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">returnspan> 
         <span class="hljs-literal">truespan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="22">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="23">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="24">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	}
        div>
       div>li>
     ol>code>
    <div class="hljs-button {2}" data-title="  " data-report-click="{
      "spm":"1001.2101.3001.4259"}" onclick="hljs.copyCode(event)">div>pre> 
   <p><img alt="" height="636" src="https://img-blog.csdnimg.cn/20210419220404289.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2RrbTEyMzQ1Ng==,size_16,color_FFFFFF,t_70" width="989" />p> 
   <h2><a name="t21">a><a name="t21">a>      h2> 
   <pre><code class="hljs kotlin">
     <ol class="hljs-ln">
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="1">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">        
         <span class="hljs-comment">// canvas2          (    2   )span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="2">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		canvas2.addEventListener(
         <span class="hljs-string">'mousemove'span>,
         <span class="hljs-keyword">thisspan>.mouseMove.bind(
         <span class="hljs-keyword">thisspan>));
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="3">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="4">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">// canvas2          (    2   )span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="5">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		canvas2.addEventListener(
         <span class="hljs-string">'click'span>,
         <span class="hljs-keyword">thisspan>.mouseClick.bind(
         <span class="hljs-keyword">thisspan>));
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="6">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="7">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">// canvas2          (    2   )span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="8">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		canvas2.addEventListener(
         <span class="hljs-string">'contextmenu'span>,
         <span class="hljs-keyword">thisspan>.contextMenu.bind(
         <span class="hljs-keyword">thisspan>));
        div>
       div>li>
     ol>code>
    <div class="hljs-button {2}" data-title="  " data-report-click="{
      "spm":"1001.2101.3001.4259"}" onclick="hljs.copyCode(event)">div>pre> 
   <h3><a name="t22">a><a name="t22">a>      h3> 
   <pre><code class="hljs kotlin">
     <ol class="hljs-ln">
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="1">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="2">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	Plants.prototype.mouseMove=function(e){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="3">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> that=
         <span class="hljs-keyword">thisspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="4">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(that.gameOver) 
         <span class="hljs-keyword">returnspan> ;
         <span class="hljs-comment">//         ,          span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="5">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!
         <span class="hljs-keyword">thisspan>.startImage) 
         <span class="hljs-keyword">returnspan>; 
         <span class="hljs-comment">//         span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="6">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> pos = _.getOffset(e);
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="7">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> isCatch = 
         <span class="hljs-keyword">thisspan>.startImage.isPoint(pos);
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="8">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="9">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!isCatch  && 
         <span class="hljs-keyword">thisspan>.gameAlive){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="10">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			isCatch = 
         <span class="hljs-keyword">thisspan>.createZombiesImage.isPoint(pos);
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="11">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="12">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="13">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="14">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(
         <span class="hljs-keyword">thisspan>.gameAlive && !
         <span class="hljs-keyword">thisspan>.currPlant) {
         <span class="hljs-comment">//    ,                  span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="15">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-comment">//        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="16">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">forspan>(
         <span class="hljs-keyword">varspan> i=
         <span class="hljs-number">0span>;i<
         <span class="hljs-keyword">thisspan>.cardRectArr.length;i++){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="17">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">varspan> item=
         <span class="hljs-keyword">thisspan>.cardRectArr[i];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="18">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">ifspan>(item.isPoint(pos) && item.alive){
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="19">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						isCatch=
         <span class="hljs-literal">truespan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="20">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">						
         <span class="hljs-keyword">breakspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="21">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="22">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="23">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="24">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="25">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="26">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="27">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">forspan>(
         <span class="hljs-keyword">varspan> i=
         <span class="hljs-number">0span>;i<
         <span class="hljs-keyword">thisspan>.suns.length;i++){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="28">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">varspan> item=
         <span class="hljs-keyword">thisspan>.suns[i];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="29">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">ifspan>(item.isPoint(pos)){
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="30">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					isCatch=
         <span class="hljs-literal">truespan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="31">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">breakspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="32">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="33">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="34">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="35">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="36">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> plant = 
         <span class="hljs-keyword">thisspan>.currPlant;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="37">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="38">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(plant){
         <span class="hljs-comment">//       ,        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="39">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-comment">//       span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="40">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">forspan>(
         <span class="hljs-keyword">varspan> i=
         <span class="hljs-number">0span>;i<
         <span class="hljs-keyword">thisspan>.bgRectArr.length;i++){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="41">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">varspan> item=
         <span class="hljs-keyword">thisspan>.bgRectArr[i];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="42">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">ifspan>(item.isPoint(pos) && !item.plant){
         <span class="hljs-comment">//    ,        span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="43">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						isCatch=
         <span class="hljs-literal">truespan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="44">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						item.fillStyle=
         <span class="hljs-string">"rgba(0,250,154, 0.5)"span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="45">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					}
         <span class="hljs-keyword">elsespan>{
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="46">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						item.fillStyle=
         <span class="hljs-string">"rgba(0,250,154, 0)"span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="47">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="48">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="49">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="50">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="51">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="52">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="53">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">thisspan>.el.style.cursor = 
         <span class="hljs-string">'pointer'span>;
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="54">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
         <span class="hljs-keyword">elsespan>{
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="55">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">thisspan>.el.style.cursor = 
         <span class="hljs-string">''span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="56">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="57">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-comment">//          span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="58">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(plant){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="59">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			plant.dx=pos.x;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="60">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			plant.dy=pos.y;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="61">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="62">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="63">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">thisspan>.render2();
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="64">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	}
        div>
       div>li>
     ol>code>
    <div class="hljs-button {2}" data-title="  " data-report-click="{
      "spm":"1001.2101.3001.4259"}" onclick="hljs.copyCode(event)">div>pre> 
   <h3><a name="t23">a><a name="t23">a>      h3> 
   <pre><code class="hljs kotlin">
     <ol class="hljs-ln">
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="1">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="2">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         	Plants.prototype.mouseClick=function(e){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="3">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(
         <span class="hljs-keyword">thisspan>.gameOver) 
         <span class="hljs-keyword">returnspan> ;
         <span class="hljs-comment">//         ,          span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="4">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> that=
         <span class="hljs-keyword">thisspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="5">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> pos = _.getOffset(e);
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="6">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">varspan> isCatch = that.startImage.isPoint(pos);
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="7">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="8">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			that.start();
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="9">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="10">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!isCatch && 
         <span class="hljs-keyword">thisspan>.gameAlive){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="11">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			isCatch = 
         <span class="hljs-keyword">thisspan>.createZombiesImage.isPoint(pos);
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="12">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="13">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				that.createZombie();
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="14">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="15">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="16">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="17">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(
         <span class="hljs-keyword">thisspan>.gameAlive && !
         <span class="hljs-keyword">thisspan>.currPlant) {
         <span class="hljs-comment">//    ,                  span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="18">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="19">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">forspan>(
         <span class="hljs-keyword">varspan> i=
         <span class="hljs-number">0span>;i<
         <span class="hljs-keyword">thisspan>.cardRectArr.length;i++){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="20">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">varspan> item=
         <span class="hljs-keyword">thisspan>.cardRectArr[i];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="21">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">ifspan>(item.isPoint(pos) && item.alive){
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="22">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						isCatch=
         <span class="hljs-literal">truespan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="23">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">						
         <span class="hljs-comment">//         ,      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="24">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">						
         <span class="hljs-keyword">thisspan>.createPlant(pos,item);
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="25">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">						
         <span class="hljs-keyword">breakspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="26">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="27">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="28">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="29">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="30">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="31">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="32">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="33">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">forspan>(
         <span class="hljs-keyword">varspan> i=
         <span class="hljs-number">0span>;i<
         <span class="hljs-keyword">thisspan>.suns.length;i++){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="34">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">varspan> item=
         <span class="hljs-keyword">thisspan>.suns[i];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="35">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">ifspan>(item.isPoint(pos)){
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="36">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					item.click && item.click();
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="37">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">breakspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="38">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="39">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         			}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="40">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         		}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="41">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">		
         <span class="hljs-keyword">ifspan>(!isCatch){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="42">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">varspan> plant = 
         <span class="hljs-keyword">thisspan>.currPlant;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="43">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">			
         <span class="hljs-keyword">ifspan>(plant){
         <span class="hljs-comment">//      span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="44">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-comment">//       span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="45">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">				
         <span class="hljs-keyword">forspan>(
         <span class="hljs-keyword">varspan> i=
         <span class="hljs-number">0span>;i<
         <span class="hljs-keyword">thisspan>.bgRectArr.length;i++){
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="46">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">varspan> item=
         <span class="hljs-keyword">thisspan>.bgRectArr[i];
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="47">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">ifspan>(item.plant) 
         <span class="hljs-keyword">continuespan>;
         <span class="hljs-comment">//       ,   span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="48">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">					
         <span class="hljs-keyword">ifspan>(item.isPoint(pos)){
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="49">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						isCatch=
         <span class="hljs-literal">truespan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="50">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						plant.dx=item.x+
         <span class="hljs-number">10span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="51">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						plant.dy=item.y+
         <span class="hljs-number">20span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="52">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						plant.index=item.index;
         <span class="hljs-comment">// plant    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="53">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						plant.alive(item);
         <span class="hljs-comment">//    span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="54">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">						
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="55">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						item.plant=
         <span class="hljs-literal">truespan>;
         <span class="hljs-comment">//     span>
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="56">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         						item.fillStyle=
         <span class="hljs-string">"rgba(0,250,154, 0)"span>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="57">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">						
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="58">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">						
         <span class="hljs-keyword">thisspan>.currPlant=
         <span class="hljs-literal">nullspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="59">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">						
         <span class="hljs-keyword">breakspan>;
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="60">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         					}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-line hljs-ln-n" data-line-number="61">div>
       div>
       <div class="hljs-ln-code">
        <div class="hljs-ln-line">
         				}
        div>
       div>li>
      <li>
       <div class="hljs-ln-numbers">
        <div class="hljs-ln-lin