最新公告
  • 欢迎您光临大资源网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!怎么把网页设置成桌面图标
  • HTML网页植物大战僵尸源码分享

    HTML网页植物大战僵尸源码分享 最后编辑:2026-06-05
    增值服务: 自动发货 使用说明 安装指导 环境配置二次开发BUG修复

    网页版植物大战僵尸游戏源码代码,植物大战僵尸优化版,HTML实现植物大战僵尸源码分享,html植物大战僵尸小游戏,游戏中的植物都有不同的特殊能力,玩家可以根据自己的喜好和策略进行选择和搭配。

    1. var game = document.getElementById(‘app’);
    2. // 获取游戏界面元素
    3. var leftUI = document.getElementById(‘leftui’);
    4. // 获取植物选择框
    5. var topUI = document.getElementById(‘topui’);
    6. // 获取植物选择框
    7. var Go = document.getElementById(‘go’);
    8. // 开始游戏按钮
    9.  
    10. // 定义游戏状态
    11. var gameState = {
    12. plants: [],// 植物列表
    13. zombies: [],// 僵尸列表
    14. energys:[],//能量列表
    15. bullets: [],// 子弹列表
    16. toolbar:[],// 顶部UI栏列表
    17. labels:[],// 植物选择框列表
    18. geids:[], // 网格坐标列表
    19. isOver: “”,// 游戏是否结束
    20. occupy:false, // 选中的植物的对象
    21. delete:false,//选择要删除的植物
    22. grade:0,//得分
    23. startTime1:0, //游戏运行时间
    24. startTime2:0, //游戏运行时间
    25. pro:0.01
    26.  
    27. };
    28.  
    29. // 定义植物属性
    30. var PlantUte = {
    31. // 向日葵
    32. SunFlower:{
    33. name:“向日葵”,
    34. price:50,
    35. uisrc1:“../images/cards/plants/SunFlower.png”,
    36. uisrc2:“../images/cards/plants/SunFlowerG.png”,
    37. datasrc:“../images/plants/sunflower/idle/idle_0.png”,
    38. url:“../images/plants/sunflower/idle/idle_”,
    39. count:17,
    40. hp:100,
    41. attack:0,
    42. speed:0,
    43. range:0,
    44. color:“red”
    45. },
    46. // 初级豌豆射手
    47. Peashooter:{
    48. name:“初级豌豆射手”,
    49. price:50,
    50. uisrc1:“../images/cards/plants/Peashooter.png”,
    51. uisrc2:“../images/cards/plants/PeashooterG.png”,
    52. datasrc:“../images/plants/peashooter/attack/attack_0.png”,
    53. url:“../images/plants/peashooter/attack/attack_”,
    54. count:7,
    55. hp:100,
    56. attack:5,
    57. speed:500,
    58. range:500,
    59. color:“chartreuse”
    60. },
    61. // 中级豌豆射手
    62. Repeater:{
    63. name:“中级豌豆射手”,
    64. price:100,
    65. uisrc1:“../images/cards/plants/Repeater.png”,
    66. uisrc2:“../images/cards/plants/RepeaterG.png”,
    67. datasrc:“../images/plants/repeater/attack/attack_0.png”,
    68. url:“../images/plants/repeater/attack/attack_”,
    69. count:14,
    70. hp:100,
    71. attack:10,
    72. speed:500,
    73. range:500,
    74. color:“chartreuse”
    75. },
    76. // 高级豌豆射手
    77. GatlingPea:{
    78. name:“高级豌豆射手”,
    79. price:200,
    80. uisrc1:“../images/cards/plants/GatlingPea.png”,
    81. uisrc2:“../images/cards/plants/GatlingPeaG.png”,
    82. datasrc:“../images/plants/gatlingpea/attack/attack_0.png”,
    83. url:“../images/plants/gatlingpea/attack/attack_”,
    84. count:12,
    85. hp:100,
    86. attack:10,
    87. speed:300,
    88. range:500,
    89. color:“chartreuse”
    90. },
    91. // 番茄炸弹
    92. CherryBomb:{
    93. name:“番茄炸弹”,
    94. price:200,
    95. uisrc1:“../images/cards/plants/CherryBomb.png”,
    96. uisrc2:“../images/cards/plants/CherryBombG.png”,
    97. datasrc:“../images/plants/cherrybomb/idle/idle_0.png”,
    98. url:“../images/plants/cherrybomb/idle/idle_”,
    99. count:6,
    100. hp:50,
    101. attack:100,
    102. speed:1000,
    103. range:57,
    104. color:“rgba(0,0,0,0)”
    105. },
    106. // 食人花
    107. Chomper:{
    108. name:“食人花”,
    109. price:300,
    110. uisrc1:“../images/cards/plants/Chomper.png”,
    111. uisrc2:“../images/cards/plants/ChomperG.png”,
    112. datasrc:“../images/plants/chomper/attack/attack_0.png”,
    113. url:“../images/plants/chomper/attack/attack_”,
    114. count:8,
    115. hp:100,
    116. attack:20,
    117. speed:100,
    118. range:57,
    119. color:“rgba(0,0,0,0)”
    120. },
    121. // 坚果防御
    122. WallNut:{
    123. name:“坚果防御”,
    124. price:50,
    125. uisrc1:“../images/cards/plants/WallNut.png”,
    126. uisrc2:“../images/cards/plants/WallNutG.png”,
    127. datasrc:“../images/plants/wallnut/idleH/idleH_0.png”,
    128. url:“../images/plants/wallnut/idleH/idleH_”,
    129. count:15,
    130. hp:1000,
    131. attack:0,
    132. speed:0,
    133. range:0,
    134. color:“red”
    135. }
    136. }
    137. // 顶部UI类
    138. function ToolBar(text,style){
    139. this.text = text;
    140. this.element = document.createElement(‘div’);
    141. this.element.className = style;
    142. this.element.innerText = this.text;
    143. topUI.appendChild(this.element); // 添加到游戏选择UI框
    144. gameState.toolbar.push(this)
    145. }
    146. // 植物选择框类
    147. function Labels(object){
    148. this.object = object;
    149. this.price=object.price;// 价格
    150. this.uisrc1 = “url(“+object.uisrc1+“)”;// UI图标路径
    151. this.uisrc2 = “url(“+object.uisrc2+“)”;
    152. this.occupy = false;//是否选中
    153. this.element = document.createElement(‘div’); // 元素节点
    154. this.element.className = ‘plantui’; // 添加样式
    155. this.element.style.backgroundImage = this.uisrc1;
    156. this.element.innerText=this.price;// 显示价格
    157. leftUI.appendChild(this.element); // 添加到游戏选择UI框
    158. gameState.labels.push(this); // 添加到植物选择框列表
    159. }
    160.  
    161. // 网格坐标类
    162. function Geid(x,y){
    163. this.x = x;
    164. this.y = y;
    165. this.occupy = false;
    166. this.element = document.createElement(“div”);
    167. this.element.className = “geid”;
    168. this.element.style.top = this.y + ‘px’; // 设置位置
    169. this.element.style.left = this.x + ‘px’;
    170. game.appendChild(this.element)
    171. gameState.geids.push(this)
    172. }
    173.  
    174. // 定义能量类
    175. function EnErgy(object){
    176. this.object = object;
    177. this.x = object.x;
    178. this.y = object.y+50;
    179. this.hp = true;
    180. this.element = document.createElement(‘img’); // 元素节点
    181. this.element.src = “../images/sun.gif” ;
    182. this.element.className = ‘energy’; // 添加样式
    183. this.element.style.top = this.y + “px”;
    184. this.element.style.left = this.x + “px”;
    185. game.appendChild(this.element); // 添加到游戏界面
    186. gameState.energys.push(this);
    187. }
    188.  
    189. // 定义植物类
    190. function Plant(x, y,object) {
    191. this.x = x;
    192. this.y = y;
    193. this.object = object;
    194. this.Animation = {
    195. src:object.datasrc,
    196. url:object.url,
    197. count:object.count,
    198. num:0,
    199. animation:false
    200. }
    201. this.set = “set”+this.x+this.y
    202. this.name = object.name;//名字
    203. this.hp = object.hp; // 血量
    204. this.attack = object.attack; // 攻击力
    205. this.speed = object.speed; // 攻击速度
    206. this.range = object.range; // 射程
    207. this.color = object.color;//攻击颜色
    208. this.lastAttackTime = 0; // 上次攻击时间
    209. this.element = document.createElement(‘div’); // 元素节点
    210. this.element.className = ‘plant’; // 添加样式
    211. this.element.style.top = this.y + ‘px’; // 设置位置
    212. this.element.style.left = this.x + ‘px’;
    213. this.element2 = document.createElement(‘img’); // 元素节点
    214. this.element2.className = ‘plantimg’; // 添加样式
    215. this.element2.src = this.Animation.src;
    216. this.element2.alt = this.name;
    217. this.element3 = document.createElement(‘span’); // 元素节点
    218. this.element3.className = ‘plantspan’; // 添加样式
    219. this.element3.innerText = this.hp;
    220.  
    221. game.appendChild(this.element); // 添加到游戏界面
    222. this.element.appendChild(this.element2); // 添加img标签
    223. this.element.appendChild(this.element3); // 添加h1标签
    224. gameState.plants.push(this); // 添加到植物列表
    225.  
    226. }
    227.  
    228. // 定义僵尸类
    229. function Zombie(x, y) {
    230. this.x = x;
    231. this.y = y;
    232. // 僵尸动画属性
    233. this.Animation = {
    234. src:“../images/zombies/run/run_0.png”,
    235. url:“../images/zombies/run/run_”,
    236. count:30,
    237. num:0,
    238. animation:false
    239. }
    240. this.hp = 100; // 血量
    241. this.attack = 1; // 攻击力
    242. this.speed = 1; // 移动速度
    243. this.speedG = 50; // 攻击速度
    244. this.range = 50; // 射程
    245. this.rice = false;
    246. this.lastAttackTime = 0; // 上次攻击时间
    247. this.element = document.createElement(‘div’); // 元素节点
    248. this.element.className = ‘zombie’; // 添加样式
    249. this.element.style.top = this.y + ‘px’; // 设置位置
    250. this.element.style.left = this.x + ‘px’;
    251. this.element2 = document.createElement(‘img’); // 元素节点
    252. this.element2.className = ‘zombieimg’; // 添加样式
    253. this.element2.src = this.Animation.src;
    254. this.element3 = document.createElement(‘span’); // 元素节点
    255. this.element3.className = ‘zombiespan’; // 添加样式
    256. this.element3.innerText = this.hp;
    257. game.appendChild(this.element); // 添加到游戏界面
    258. this.element.appendChild(this.element3); // 添加img标签
    259. this.element.appendChild(this.element2); // 添加img标签
    260. gameState.zombies.push(this); // 添加到僵尸列表
    261. }
    262.  
    263. // 定义子弹类
    264. function Bullet(plant, target) {
    265. this.x = plant.x;
    266. this.y = plant.y;
    267. this.speed = 5; // 移动速度
    268. this.attack = plant.attack;//攻击大小
    269. this.target = target; // 目标对象
    270. this.element = document.createElement(‘div’); // 元素节点
    271. this.element.className = ‘bullet’; // 添加样式
    272. this.element.style.backgroundColor = plant.color;//子弹颜色
    273. this.element.style.borderColor = plant.color;
    274. this.element.style.left = this.x + ‘px’;// 设置位置
    275. this.element.style.top = this.y + ‘px’;
    276. game.appendChild(this.element); // 添加到游戏界面
    277. gameState.bullets.push(this); // 添加到子弹列表
    278. }
    279.  
    280. // 初始化选择框UI
    281. var InitUI = function(){
    282.  
    283. // 初始化网格线坐标
    284. for(var i=0;i<5;i++){
    285. for(var j=0;j<9;j++){
    286. new Geid(parseInt(j*80+240),parseInt(i*100+60))
    287. }
    288. }
    289.  
    290. // 创建顶部UI信息栏对象实例
    291. new ToolBar(500,“vessel”);//能量收集
    292. new ToolBar(“”,“delete”); //铲子
    293. new ToolBar(0,“grade”); //销毁僵尸数量
    294. new ToolBar(“00:00”,“nz”); //游戏时间
    295.  
    296. // 创建UI标签栏对象实例
    297. new Labels(PlantUte.SunFlower); //向日葵
    298. new Labels(PlantUte.Peashooter); //初级豌豆射手
    299. new Labels(PlantUte.Repeater); //中级豌豆射手
    300. new Labels(PlantUte.GatlingPea); //高级豌豆射手
    301. // new Labels(PlantUte.CherryBomb); //番茄炸弹
    302. new Labels(PlantUte.Chomper); //食人花
    303. new Labels(PlantUte.WallNut); //坚果防御
    304. }
    305.  
    306. // 游戏时间
    307. var Initnz = function(){
    308. let time = Date.now()-gameState.startTime2;
    309. var date = new Date(time);
    310. var m = (date.getMinutes() < 10 ? ‘0’ + (date.getMinutes()) : date.getMinutes()) + ‘:’;
    311. var s = (date.getSeconds() < 10 ? ‘0’ + (date.getSeconds()) : date.getSeconds());
    312. var strDate = m+s;
    313. gameState.toolbar[3].element.innerText = strDate;
    314. }
    315.  
    316. // 开始游戏按钮
    317. Go.onclick = function(){
    318. console.log(“开始游戏”);
    319. InitUI();
    320. gameState.startTime1 = Date.now();
    321. gameState.startTime2 = Date.now();
    322. // 游戏主循环定时器
    323. var Appset = setInterval(function(){
    324. // 游戏时间
    325. Initnz()
    326. // 随机生成僵尸
    327. if (Math.random() < gameState.pro) {
    328. console.log(“生成僵尸:”,gameState.pro)
    329. new Zombie(1130, parseInt(Math.random()*5)*100+60);
    330. }
    331.  
    332. // 选择要种植的植物
    333. gameState.labels.forEach(function(label){
    334. if(label.price <= gameState.toolbar[0].element.innerText){
    335. label.element.style.backgroundImage = label.uisrc1;
    336. label.element.style.color = “black”;
    337. }else{
    338. label.element.style.backgroundImage = label.uisrc2;
    339. label.element.style.color = “red”;
    340. }
    341. label.element.onclick = function(){
    342. if(gameState.toolbar[0].element.innerText >= label.price){
    343. gameState.occupy = label.object;
    344. gameState.geids.forEach(function(geid){
    345. if(geid.occupy){
    346. geid.element.style.borderColor=“rgba(251, 4, 4,0.5)”;
    347. }else{
    348. geid.element.style.borderColor=“rgba(222, 251, 4, 0.759)”;
    349. }
    350. })
    351. }
    352. }
    353. })
    354.  
    355. // 选择生成植物的网格坐标
    356. gameState.geids.forEach(function(geid){
    357. geid.element.onclick = function(){
    358. if(gameState.occupy){
    359. geid.occupy = true
    360. new Plant(geid.x,geid.y,gameState.occupy);
    361. gameState.toolbar[0].element.innerText -=gameState.occupy.price;
    362. gameState.occupy=false;
    363. gameState.geids.forEach(function(geid){
    364. geid.element.style.borderColor=“rgba(0, 0, 0,0)”;
    365. })
    366. }
    367. }
    368. })
    369.  
    370. // 僵尸移动
    371. gameState.zombies.forEach(function(zombie) {
    372. if(zombie.x>=170){
    373. zombie.x -= zombie.speed;
    374. zombie.element.style.left = zombie.x + ‘px’;
    375. }else{
    376. gameState.isOver = “挑战失败”;
    377. }
    378. });
    379. // 植物攻击僵尸
    380. gameState.plants.forEach(function(plant) {
    381. gameState.zombies.forEach(function(zombie) {
    382. if(zombie.y == plant.y){
    383. if (zombie.x plant.x <= plant.range && zombie.x > plant.x) {
    384. if (Date.now() plant.lastAttackTime >= plant.speed) {
    385. new Bullet(plant,zombie);
    386. plant.lastAttackTime = Date.now();
    387. if (zombie.hp <= 0) {
    388. gameState.toolbar[2].element.innerText = ++gameState.grade;
    389. game.removeChild(zombie.element);
    390. gameState.zombies.splice(gameState.zombies.indexOf(zombie), 1);
    391. }
    392. }
    393. }
    394. }
    395. });
    396. });
    397.  
    398. // 僵尸攻击植物
    399. gameState.zombies.forEach(function(zombie) {
    400. gameState.plants.forEach(function(plant) {
    401. if(zombie.y == plant.y){
    402. if(zombie.xplant.x <= zombie.range && zombie.x > plant.x ){
    403. zombie.x = plant.x+zombie.range;
    404. zombie.rice = true;
    405. if (Date.now() zombie.lastAttackTime >= zombie.speedG) {
    406. plant.hp-=zombie.attack;
    407. // zombie.rice = true;
    408. plant.element3.innerText = plant.hp;
    409. zombie.lastAttackTime = Date.now();
    410. }
    411. // zombie.rice = false;
    412. }else{
    413. zombie.rice = false;
    414. }
    415. }
    416. // zombie.rice = false;
    417. });
    418. });
    419.  
    420. // 判断该植物是否死亡,释放网格资源
    421. gameState.plants.forEach(function(plant){
    422. gameState.geids.forEach(function(geid){
    423. if(plant.hp<=0){
    424. if(geid.x == plant.x && geid.y == plant.y){
    425. geid.occupy = false;
    426. game.removeChild(plant.element);
    427. gameState.plants.splice(gameState.plants.indexOf(plant), 1);
    428. }
    429. }
    430. })
    431. })
    432.  
    433. // 检测子弹是否击中目标
    434. gameState.bullets.forEach(function(bullet) {
    435. if (bullet.target && Math.abs(bullet.x bullet.target.x) < 60) {
    436. bullet.target.hp -= bullet.attack;
    437. bullet.target.element3.innerText = bullet.target.hp;
    438. game.removeChild(bullet.element);
    439. gameState.bullets.splice(gameState.bullets.indexOf(bullet), 1);
    440. } else {
    441. bullet.x += bullet.speed;
    442. bullet.element.style.left = bullet.x + ‘px’;
    443. }
    444. });
    445.  
    446. // 选择要删除的植物
    447. gameState.toolbar[1].element.onclick = function(){
    448. console.log(“删除植物”);
    449. gameState.delete = true;
    450. gameState.geids.forEach(function(geid){
    451. if(geid.occupy){
    452. geid.element.style.borderColor=“rgba(222, 251, 4, 0.759)”;
    453. }else{
    454. geid.element.style.borderColor=“rgba(251, 4, 4,0.5)”;
    455. }
    456.  
    457. })
    458.  
    459. }
    460.  
    461. // 选择删除植物的网格坐标
    462. gameState.plants.forEach(function(plant){
    463. plant.element.ondblclick = function(){
    464. gameState.geids.forEach(function(geid){
    465. if(gameState.delete){
    466. if(geid.x == plant.x && geid.y == plant.y){
    467. geid.occupy = false;
    468. gameState.delete = false;
    469. plant.hp = 0;
    470. game.removeChild(plant.element);
    471. gameState.plants.splice(gameState.plants.indexOf(plant), 1);
    472. }
    473. gameState.geids.forEach(function(geid){
    474. geid.element.style.borderColor=“rgba(0, 0, 0,0)”;
    475. })
    476. }
    477. })
    478. }
    479.  
    480. })
    481.  
    482. // 游戏难度,每1分钟提升难度
    483. if(Date.now()-gameState.startTime1>=60000){
    484. gameState.startTime1 = Date.now();
    485. gameState.pro = gameState.pro+0.01;
    486. console.log(“难度升级:”,gameState.pro);
    487. if(gameState.pro >=0.02){
    488. game.style.backgroundImage = “url(../images/background2.jpg)”;
    489. }
    490. if(gameState.pro >=0.04){
    491. game.style.backgroundImage = “url(../images/background1.jpg)”;
    492. }
    493. if(gameState.pro >=0.06){
    494. game.style.backgroundImage = “url(../images/background2.jpg)”;
    495. }
    496. if(gameState.pro >=0.07){
    497. gameState.isOver = “挑战成功”;
    498. }
    499. }
    500.  
    501. // 植物动画
    502. gameState.plants.forEach(function(plant){
    503. if(!plant.Animation.animation){
    504. var plantSet = setInterval(function(){
    505. if(plant.name == “坚果防御” && plant.hp<600 && plant.hp >=300){
    506. plant.Animation.src = “../images/plants/wallnut/idleM/idleM_0.png”;
    507. plant.Animation.url = “../images/plants/wallnut/idleM/idleM_”;
    508. plant.Animation.count = 10;
    509. }
    510. if(plant.name == “坚果防御” && plant.hp<300){
    511. plant.Animation.src = “../images/plants/wallnut/idleL/idleL_0.png”;
    512. plant.Animation.url = “../images/plants/wallnut/idleL/idleL_”;
    513. plant.Animation.count = 14;
    514. }
    515. if(plant.Animation.num<=plant.Animation.count){
    516. plant.element2.src = plant.Animation.url+plant.Animation.num+“.png”;
    517. plant.Animation.num++;
    518. }else{
    519. plant.Animation.num=0;
    520. }
    521. if(plant.hp<=0){
    522. clearInterval(plantSet);
    523. }
    524. },100);
    525. plant.Animation.animation = !plant.Animation.animation;
    526. }
    527. })
    528.  
    529. // 僵尸动画
    530. gameState.zombies.forEach(function(zombie){
    531. if(!zombie.Animation.animation){
    532. var zombieSet = setInterval(function(){
    533. if(zombie.hp>20 && zombie.rice){
    534. zombie.Animation.src = “../images/zombies/attack_0.png”;
    535. zombie.Animation.url = “../images/zombies/attack/attack_”;
    536. zombie.Animation.count = 20;
    537. }else{
    538. zombie.Animation.src = “../images/zombies/run/run_0.png”;
    539. zombie.Animation.url = “../images/zombies/run/run_”;
    540. zombie.Animation.count = 30;
    541. }
    542. if(zombie.hp<=20){
    543. zombie.Animation.src = “../images/zombies/dying/body/body_0.png”;
    544. zombie.Animation.url = “../images/zombies/dying/body/body_”;
    545. zombie.Animation.count = 17;
    546. }
    547. if(zombie.hp<=5){
    548. zombie.Animation.src = “../images/zombies/die/die_0.png”;
    549. zombie.Animation.url = “../images/zombies/die/die_”;
    550. zombie.Animation.count = 9;
    551. }
    552. if(zombie.hp<=1){
    553. zombie.Animation.src = “../images/zombies/dying/head/head_0.png”;
    554. zombie.Animation.url = “../images/zombies/dying/head/head_”;
    555. zombie.Animation.count = 11;
    556. }
    557. if(zombie.Animation.num<=zombie.Animation.count){
    558. zombie.element2.src = zombie.Animation.url+zombie.Animation.num+“.png”;
    559. zombie.Animation.num++;
    560. }else{
    561. zombie.Animation.num=0;
    562. }
    563. if(zombie.hp<=0){
    564. clearInterval(zombieSet);
    565. }
    566.  
    567. },50);
    568. zombie.Animation.animation = !zombie.Animation.animation;
    569. }
    570. })
    571.  
    572. // 产生小太阳
    573. gameState.plants.forEach(function(plant){
    574. if(plant.name == “向日葵”){
    575. plant.name = “向日葵2”;
    576. var energyset = setInterval(function(){
    577. if(plant.hp>0){
    578. new EnErgy(plant);
    579. }else{
    580. clearInterval(energyset);
    581. }
    582. },10000)
    583. }
    584. })
    585.  
    586. // 销毁小太阳
    587. gameState.energys.forEach(function(energy){
    588. if(energy.hp){
    589. energy.hp = false;
    590. var energyYD = setInterval(function(){
    591. if(energy.y>10){
    592. energy.y–;
    593. energy.element.style.top = energy.y+“px”;
    594. }
    595. if(energy.x>140){
    596. energy.x–;
    597. energy.element.style.left = energy.x+“px”;
    598. }
    599. if(energy.x <= 140 && energy.y <=10){
    600. clearInterval(energyYD);
    601. gameState.toolbar[0].element.innerText =parseInt(gameState.toolbar[0].element.innerText)+10;
    602. game.removeChild(energy.element);
    603. gameState.energys.splice(gameState.energys.indexOf(energy), 1);
    604.  
    605. }
    606. },10)
    607. }
    608.  
    609. })
    610.  
    611. // 如果游戏结束,停止循环
    612. if (gameState.isOver == “挑战失败”) {
    613. var End = document.createElement(‘div’); // 元素节点
    614. End.className = “end”;
    615. game.appendChild(End);
    616. clearInterval(Appset);
    617. End.ondblclick = function(){
    618. game.removeChild(End);
    619. location.reload();
    620. }
    621. }
    622.  
    623. // 如果游戏通过,停止循环
    624. if (gameState.isOver == “挑战成功”) {
    625. var End = document.createElement(‘div’); // 元素节点
    626. End.className = “vict”;
    627. End.innerText = gameState.grade;
    628. game.appendChild(End);
    629. clearInterval(Appset);
    630. End.ondblclick = function(){
    631. game.removeChild(End);
    632. location.reload();
    633. }
    634. }
    635.  
    636. }, 50);
    637. setInterval(function(){
    638. gameState.toolbar[0].element.innerText++;
    639. }, 1000);
    640. game.removeChild(Go);
    641. }

    植物选择栏:可以选择自己要种植的植物。

    顶部为UI栏:

    -能量值:游戏开始后,每秒能量值+1 ,可以通过种植向日葵来增加能量值。

    -击败僵尸数:展示玩家击败的僵尸数量,同时也是游戏最后得分。

    -铲子:可以删除玩家种植的植物。点击选择铲子,然后双击植物,挖掉植物。

    -游戏时间:展示当前游戏运行的时间。

    猜你在找

    常见问题FAQ

    免费下载或者VIP会员专享资源能否直接商用?
    本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
    提示下载完但解压或打开不了?
    最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。若排除这种情况,可在对应资源底部留言,或 联络我们.。
    找不到素材资源介绍文章里的示例图片?
    对于PPT,KEY,Mockups,APP,网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。
    大资源
    一个高级程序员模板开发平台
    • 2026-06-05Hi,初次和大家见面了,请多关照!

    发表评论

    售后服务:

    • 售后服务范围 1、商业模板使用范围内问题免费咨询
      2、源码安装、模板安装(一般 ¥50-300)服务答疑仅限SVIP用户
      3、单价超过200元的模板免费一次安装,需提供服务器信息。
      付费增值服务 1、提供dedecms模板、WordPress主题、discuz模板优化等服务请详询在线客服
      2、承接 WordPress、DedeCMS、Discuz 等系统建站、仿站、开发、定制等服务
      3、服务器环境配置(一般 ¥50-300)
      4、网站的问题处理(需额外付费,500元/次/质保三个月)
      售后服务时间 周一至周日(法定节假日除外) 9:00-23:00
      免责声明 本站所提供的模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: 3482249445@qq.com),我们会及时删除,给您带来的不便,我们深表歉意!

    Hi, 如果你对这款模板有疑问,可以跟我联系哦!

    联系作者
    • 7031会员总数(位)
    • 163597资源总数(个)
    • 2712本周发布(个)
    • 2102今日发布(个)
    • 3687稳定运行(天)

    开通VIP 知识课堂
    升级SVIP尊享更多特权立即升级
    My title page contents
    召唤伊斯特瓦尔