JavaScript Canvasに基づく植物大戦ゾンビ、週末爆肝作----------------------------(下)
968369 ワード
前のソースコードに続く
クリックして前編にジャンプhttps://blog.csdn.net/weixin_44070254/article/details/115972451?spm=1001.2014.3001.5501
クリックして前編にジャンプ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>