栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

基于SSM框架开发设计java游戏制作源码仿pk基于c/s开发角色扮演swing,有血量、装备、攻击、怪物等(源码+数据库文件)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基于SSM框架开发设计java游戏制作源码仿pk基于c/s开发角色扮演swing,有血量、装备、攻击、怪物等(源码+数据库文件)

适合初学者进阶游戏开发的java设计,游戏简单,W、S、A、D控制方向按键,K、L属性攻击键,主要框架SSM,mysql8.0数据库,使用IntelliJ IDEA开发工具可以直接导入,运行该程序。

游戏界面截图:

源码

@Override
	public void paint(Graphics g) {
		super.paint(g);
		if (x > 19)
			x = 0;
		else
			x++;
		y1--;
		g.setColor(new Color(255, 255, 255, calculate(x)));
		g.setFont(new Font("宋体", Font.BOLD, 40));
		g.drawString(Welcome, 360, 100);
		g.drawString("按Enter键,可快速跳过 ", 700, 800);

		int z1 = 20;
		int lenth = info.length() / z1;
		int y0 = 0;
		int z0;
		for (int i = 0; i <= lenth; i++) {
			int z2 = 45;
			y0 = z2 * i + y1;
			int y3 = 510;
			int y2 = 450;
			if (y0 < y2)
				z0 = 255 - y2 + y0 < 0 ? 0 : 255 - y2 + y0;
			else if (y0 > y3)
				z0 = 255 + y3 - y0 < 0 ? 0 : 255 + y3 - y0;
			else
				z0 = 255;
			g.setColor(new Color(255, 255, 255, z0));
			int x1 = 200;
			if (i == lenth) {
				g.drawString(info.substring(i * z1), x1, y0);
			} else {
				g.drawString(info.substring(i * z1, (i + 1) * z1), x1, y0);
			}
		}
		if (y0 < 400) TF = false;
	}


ChooseLeave(int x, int y) {
		this.setLayout(null);
		int height = 600;
		int width = 800;
		this.setBounds(x, y, width, height);
		this.addMouseWheelListener(this);
		buttons = new ArrayList<>();
		for (int i = 1; i <= 10; i++) {
			JButton jButton = new JButton("第" + i + "关
"); jButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) throws StringIndexOutOfBoundsException { int leave = Integer.valueOf(jButton.getText().substring(7, 8)); // System.out.println(nowLeave+"|"+leave); if (nowLeave == -1) { nowLeave = leave; GameController.leave = nowLeave; ClientStart.OutStreamAll(GameController.own_cilent_id + ":0207:" + leave + ":+:" + info); AddButtonInfo(nowLeave, info); readyButton(); } else if (nowLeave == leave) { removeReady(); } else { ClientStart.OutStreamAll(GameController.own_cilent_id + ":0207:" + nowLeave + ":-:" + info); SubButtonInfo(nowLeave, info); ClientStart.OutStreamAll(GameController.own_cilent_id + ":0207:" + leave + ":+:" + info); AddButtonInfo(leave, info); nowLeave = leave; GameController.leave = nowLeave; readyButton(); } } }); if (i > leaves) { jButton.setEnabled(false); jButton.setText("未达到通关条件"); jButton.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green)); } else { jButton.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green)); } jButton.setSize(165, 60); if (i == 1) first_button = 100 * i; else last_button = 100 * i; if (i % 2 == 0) jButton.setLocation(50, 100 * i); else jButton.setLocation(300, 100 * i); buttons.add(jButton); this.add(jButton); } JButton back = new JButton("返回上一层"); back.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.red)); back.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent arg0) { if (ready != null) { id_State.put(GameController.own_cilent_id, 0); jPanel.remove(ready); ready = null; } ChooseChapter.ToMain(); nowLeave = -1; } }); back.setBounds(650, 50, 120, 60); this.add(back); this.setBackground(new Color(167, 83, 90)); jPanel = this; } private static void setPlayGameButton() { int ready = -1; for (Integer i : id_State.keySet()) { if (ready == -1) ready = id_State.get(i); else if (ready != id_State.get(i)) { ready = -1; break; } } if (ready > 0) { playGameButton = new JButton("开始游戏"); playGameButton.addActionListener((A) -> { playGame(); ClientStart.OutStreamAll(GameController.own_cilent_id + ":0404"); }); playGameButton.setBounds(500, 50, 120, 60); playGameButton.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green)); jPanel.add(playGameButton); } else { if (playGameButton != null) jPanel.remove(playGameButton); } jPanel.repaint(); }

@Override
	public void run() {
		while (TF) {
			repaint();
			try {
				Thread.sleep(30);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

		ClientStart.OutStreamAll("1:0402");

		GameJFrame.GameJFrame.remove(this);
		GameJFrame.GameJFrame.add(gameContrller);

		BackPack pack = new BackPack(gameContrller);// 背包
		pack.setBounds(1060, 740, 80, 80);
		GameJFrame.GameJFrame.add(pack);

		Shop shop = new Shop(gameContrller);// 商城
		shop.setBounds(900, 740, 80, 80);
		GameJFrame.GameJFrame.add(shop);

		InputPack input = new InputPack(gameContrller);// 输入框
		input.setBounds(30, 550, 260, 35);
		GameJFrame.GameJFrame.add(input);

		ExitGame exit = new ExitGame(gameContrller);
		exit.setBounds(GameController.exit_x, GameController.exit_y, GameController.exit_width, GameController.exit_height);
		GameJFrame.GameJFrame.add(exit);

		Information information = new Information();// 个人信息
		information.setBounds(GameController.info_x, GameController.info_y, GameController.info_width, GameController.info_height);
		GameJFrame.GameJFrame.add(information);

		GameJFrame.repaintJFrame();

		new Goods_infor("start");
	}

源码下载地址:请点击》》》

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1025772.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号