基于SSM框架开发设计java游戏制作源码仿pk基于c/s开发角色扮演swing,有血量装备攻击怪物等(源码+数据库文件)
Posted weixin_ancenhw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于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("<html>第" + i + "关<br></html>");
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");
以上是关于基于SSM框架开发设计java游戏制作源码仿pk基于c/s开发角色扮演swing,有血量装备攻击怪物等(源码+数据库文件)的主要内容,如果未能解决你的问题,请参考以下文章
java SSM框架 代码生成器 websocket即时通讯 shiro redis 后台框架源码
java SSM框架 代码生成器 websocket即时通讯 shiro redis 后台框架源码
java ssm 后台框架平台 项目源码 websocket 即时通讯 IM quartz spri
基于SSM框架java项目健身房管理系统.rar(项目源码)毕业设计私人教练预约