保卫萝⼘项⽬(java端)
注:游戏开发样式借鉴原“保卫萝⼘3”
运⽤技术
1:java 继承 封装 多肽 以及绘图⼯具 ⽂件的输⼊流
开发⼯具 Eclipse ps。
界⾯效果
1:游戏启动窗⼝
2:冒险模式
3:关卡内效果
部分代码展⽰
1:⾓⾊⼯⼚
package game;
import java.util.ArrayList;
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.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;
=1000;
Loading=true;
Daoshu=true;
}
}
2:记分版
李念哥哥李思个人资料
package game.FormArea;
import java.awt.Color;
import java.awt.Font;
import game.Factory;
sources.Res;
import net.zj.game.Pen;
public class FormArea {
public int x;
public int y;
得房率什么意思public int money=1000;
public FormArea(int x,int y){
贡米身高
this.x=x;
this.y=y;
}
/**
* 绘制
*/
public void draw(){
Pen.drawImage(Res.Pic.formArea, x,y,null);//计分板
Pen.setColor(Color.YELLOW);
Pen.setFont(new Font("Tohoma",Font.BOLD,24));
Pen.drawString(money+"", 250, 60);
}
}
3:启动窗⼝
package game.StartWindow;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import game.Factory;
sources.Res;
import net.zj.game.GameFrame;
import net.zj.game.Pen;
public class StartWindow extends GameFrame {
public int x;
public int y;
public StartWindow(){
setSize(1024,512);//窗⼝⼤⼩ (正常显⽰的窗⼝⼤⼩为1000)
setTitle("保卫萝⼘");//标题
setVisible(false);//是否显⽰
setCenter();//窗⼝居中
setbackImage(Res.Pic.backImg);
Res.Music.BGmusic.play();//添加游戏住背景⾳乐
Res.Music.BGmusic.loop();//背景⾳乐循环播放
}
@Override
public void mouseClicked(MouseEvent e) {
Factory.maoxian.X(), e.getY());
}
@Override
public void animate() {
Pen.drawImage(Res.Pic.name, 380, 130, null);
Pen.drawGif(Res.Pic.a, 300, 100, null);
Factory.maoxian.draw();
Factory.boss.draw();
Factory.guaiwu.draw();
}
/**
* 居中让游戏窗⼝居中
*/
public void setCenter(){
int DefaultToolkit().getScreenSize().width;
int DefaultToolkit().getScreenSize().height;
this.setLocation((width-1024)/2,(height-512)/2);
}
}
4:怪物类(抽象)
package game.Monsters;
import java.awt.Color;
import game.Factory;
import game.Luobu;
sources.Res;
import net.zj.game.Pen;
import net.zj.game.TimerTicker;
import net.zj.game.gifutil.GIF;
/**
* 怪物抽象类
*
*/
public abstract class Monster {
public int x, y;// x,y坐标
public int dir;// ⽅向,(0为上,1为右,2为下,3为左)
public int lbDir;// 萝⼘在怪物的哪个⽅向,⽤以控制怪物吃掉萝⼘(0为上,1为右,2为下,3为左)