注:游戏开发样式借鉴原“保卫萝卜3”
运用技术
1:java 继承 封装 多肽 以及绘图工具 文件的输入流
开发工具 Eclipse ps。
界面效果
1:游戏启动窗口
2:冒险模式
3:关卡内效果
部分代码展示
1:角色工厂
package game;
import java.util.ArrayList;
import org.omg.CORBA.PUBLIC_MEMBER;
import game.Attack.Attacks;
import game.Attack.Attacks;
import game.Explod.Explod_T;
import game.FormArea.*;
import game.MaoxianWindow.*;
import game.MaoxianWindow.ChangJing1.*;
import game.MaoxianWindow.GuanKa.GuanKa;
import game.MaoxianWindow.GuanKa.GuanKa1;
import game.Monsters.*;
import game.Obstacles.*;
import game.Paota.*;
import game.StartWindow.*;
import game.Themes.*;
public class Factory {
// 游戏中最开始被默认隐藏的角色
// 窗口选择(初始都为不显示)
// 游戏主窗口
public static StartWindow startWindow = null;
// 关卡窗口
public static ThemesWindow ThemesWindow = null;
// 冒险窗口
public static MaoxianWindow maoxianWindow = null;
// 选择关卡窗口
public static ChangeGuanKaWindow changethemeswindow = null;
// 金币
public static FormArea formarer = new FormArea(198,30);
// 菜单按钮
public static Form form = new Form(760, 30);
// 暂停
public static Stop stop = new Stop(700, 32);
public static GameStop gamestop = new GameStop(430, 34);
// 初始游戏窗口选项按钮
public static Maoxian maoxian = new Maoxian(100, 420);
public static Boss boss = new Boss(410, 420);
public static Guaiwu guaiwu = new Guaiwu(720, 420);
// 关卡的选择
public static Getback getback = new Getback(50, 33);
public static Return ret = new Return(200, 415);
public static ChangJing1 changjing1 = new ChangJing1(50, 100);
public static ChangJing2 changjing2 = new ChangJing2(400, 100);
public static ChangJing3 changjing3 = new ChangJing3(750, 100);
public static ChangJing4 changjing4 = new ChangJing4(50, 300);
public static ChangJing5 changjing5 = new ChangJing5(400, 300);
public static More more = new More(750, 300);
public static GuanKa guanka = null;
//大关卡
public static int DaGuanKa = 0;
// 障碍物
public static ArrayList<Obstacles> obstacle = new ArrayList<Obstacles>();
// 菜单
public static GameMenue gamemenue = new GameMenue(312, 126);
// 萝卜
public static Luobu luobu = new Luobu();
// 游戏中怪物的行走路径
public static RoadWay roadWay = new RoadWay();
// 把场景创建进角色工厂
public static Theme theme = null;
// 炮塔动态数组
public static ArrayList<Paota> paotas = new ArrayList<Paota>();
//选地
public static Location change =new Location();
//建塔
public static PaotaCard paotacards=new PaotaCard();
//升级
public static Upup up=new Upup();
//加载中。。。
public static boolean Loading = false;
//倒数
public static boolean Daoshu=false;
// 测试monster
public static ArrayList<Monster> monsters = new ArrayList<Monster>();
// 测试爆炸效果
public static ArrayList<Explod_T> e_t = new ArrayList<Explod_T>();
// 测试子弹
public static ArrayList<Attacks> T_A = new ArrayList<Attacks>();
//游戏暂停
public static boolean Stop =false;
//重新开始
public static void NewGame(){
roadWay.TackNum();
paotas = new ArrayList<Paota>();
monsters = new ArrayList<Monster>();
T_A = new ArrayList<Attacks>();
e_t = new ArrayList<Explod_T>();
Stop =false;
up=new Upup();
paotacards=new PaotaCard();
change =new Location();
luobu.hp=7;
theme.monsterCount=7;
Factory.formarer.money=1000;
Loading=t