纯java游戏-植物大战僵尸源码


纯java游戏-植物大战僵尸源码,采用java的Swing组件以及java线程实现,经本人测试有点小卡,不过功能都实现了,我也是网上搜索好久收集到了,分享啦!
资源截图
代码片段和文件信息
package plantvsplant;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

import plantvsplant.entity.Cell;
import plantvsplant.entity.Corpse;
import plantvsplant.entity.Grid;
import plantvsplant.entity.Plant;
import plantvsplant.tool.BulletMoveThread;
import plantvsplant.tool.CarThread;
import plantvsplant.tool.CorpseMoveThread;
import plantvsplant.tool.MoneyEnoughThread;
import plantvsplant.tool.ProduceBullet;
import plantvsplant.tool.SunAdd;
import plantvsplant.tool.SunAutoProduceThread;
import plantvsplant.tool.SunflowerProduceThread;
import plantvsplant.tool.Timer;
import plantvsplant.tool.plantTrainThread;
import plantvsplant.win.IndexWin;
import plantvsplant.win.MyLabel;
import plantvsplant.win.Win;

public class Controller {
private Win win;
private Grid grid;
private IndexWin indexwin;
private int x;
private int y;
private int length=28;
private String plantType = “00111“;
private Timer timer;
private int sunValue;
private int corpseNum;
private boolean uproot=false;//断定 能够挖除植物 0可以挖除
private int operation = 0;//0添加植物 1铲除植物
private MoneyEnoughThread moneyEnoughThread;
private Map carRunList=new HashMap();
private Map bulletList=new HashMap();
private SunAutoProduceThread sunAutoProduceThread;
private Map plantList=new HashMap();
private Map carList=new HashMap();
private Map corpseList=new HashMap();
private Map produceBulletTimer=new HashMap();
public Controller(){
indexwin=new IndexWin(this);

}
public void start(){
SunAdd.stop=false;
this.x=15;
this.y=80;
grid=new Grid(this.xthis.y);
sunValue=50;
win=Win.getWin(this);
timer=new Timer(this);
//grid.start();
indexwin.setVisible(false);
sunAutoProduceThread = new SunAutoProduceThread(this);
moneyEnoughThread = new MoneyEnoughThread(this);
win.toShow();
putSunValue(0);
timer.start();
sunAutoProduceThread.start();
moneyEnoughThread.start();
grid.getBoard()[1][0]=“31111“;
grid.getBoard()[4][0]=“31111“;
grid.getBoard()[7][0]=“31111“;
grid.getBoard()[10][0]=“31111“;
grid.getBoard()[13][0]=“31111“;
corpseNum=grid.getNum();

}
public void newCorpseThread(){
for (int i = 0; i < grid.getBoard().length; i++) {
if(“11121314“.contains(grid.getBoard()[i][length-1].substring(02))&&
corpseList.get(grid.getBoard()[i][length-1])==null){
corpseList.put(grid.getBoard()[i][length-1] new CorpseMoveThread(thisi length-1));
corpseList.get(grid.getBoard()[i][length-1]).start();
}
}
}
public int  moveBullet(int xint y){
if(y+1==length-1&&grid.getBoard()[x][y].equals(“21bullet“)){
grid.g

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-11-14 14:36  游戏-植物大战僵尸
     目录           0  2014-11-14 14:32  游戏-植物大战僵尸plantVScorpse
     文件         226  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpse.classpath
     文件         372  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpse.project
     目录           0  2012-06-16 07:05  游戏-植物大战僵尸plantVScorpse.settings
     文件          88  2011-10-10 11:06  游戏-植物大战僵尸plantVScorpse.settingsorg.eclipse.core.resources.prefs
     目录           0  2012-06-16 07:05  游戏-植物大战僵尸plantVScorpsein
     目录           0  2012-06-16 07:05  游戏-植物大战僵尸plantVScorpseinplantvsplant
     目录           0  2012-06-16 07:05  游戏-植物大战僵尸plantVScorpseinplantvsplantcard
     文件        2479  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcard1.jpg
     文件        2882  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcard2.jpg
     文件        2889  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcard3.jpg
     文件        2829  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcard4.jpg
     文件        2666  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcard5.jpg
     文件        2893  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcard6.jpg
     文件        2886  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcard7.jpg
     文件        2673  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcard8.jpg
     文件       18645  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcardcardboard.png
     文件        1861  2011-10-13 16:11  游戏-植物大战僵尸plantVScorpseinplantvsplantController$1.class
     文件         876  2011-10-13 16:11  游戏-植物大战僵尸plantVScorpseinplantvsplantController$2.class
     文件        1205  2011-10-13 16:11  游戏-植物大战僵尸plantVScorpseinplantvsplantController$3.class
     文件       19449  2011-10-13 16:11  游戏-植物大战僵尸plantVScorpseinplantvsplantController.class
     目录           0  2012-06-16 07:05  游戏-植物大战僵尸plantVScorpseinplantvsplantcorpsel
     文件       12968  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcorpsel440011332-3.png
     文件       16209  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcorpsel4400121322-3.png
     文件        9957  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcorpsel11.png
     文件       12229  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcorpsel22.png
     文件        7787  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcorpsel231641391097.jpg
     文件        8949  2011-09-30 15:12  游戏-植物大战僵尸plantVScorpseinplantvsplantcorpsel33.png
     目录           0  2012-06-16 07:05  游戏-植物大战僵尸plantVScorpseinplantvsplantentity
     文件        1565  2011-10-13 16:11  游戏-植物大战僵尸plantVScorpseinplantvsplantentityCell.class
............此处省略142个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)