• 大小: 7.07MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-03
  • 语言: Java
  • 标签: java  游戏  2d  swing  gui  

资源简介

想上传几张图片的发现居然上传不了 第一次用这个 本人也是第一次写java对战小游戏 写着耍了耍 代码中有分层控制逻辑到了后面不是很美丽了,不过总的来说界面还算不错,也不要积分了 ,大家可以下载跑来耍耍

资源截图

代码片段和文件信息

package com.control;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import com.model.*;

import javax.swing.ImageIcon;
import javax.swing.Jframe;
import javax.swing.JPanel;

import com.view.*;
public class Game_P_con implements KeyListener{
JPanel jpanelPlayGame;
Game_Play_Jframe game_Play_Jframe;
JPanel jpone;
PlayImage playImage;
private static int jsx=0;
    private static int jsh=0;
    static int index=1;
static int idexfz=4;
static int idexgj=8;
static int indexgjfz=10;
static int indexaida=12;
int ssqx=0;
MghThread mghThread;
//自己坐标
int xmy=0;
int ymy=0;
//判断方向
    boolean bl=false;
    //判断悬空
    boolean blxk=false;
    Image gdimage=new ImageIcon(“fz_image/d7.png“).getImage();
    int gjfx;
    
  

public Game_P_con(JPanel jpanelPlayGameJPanel jponeGame_Play_Jframe game_Play_Jframe)
{
playImage=new PlayImage();
mghThread=new MghThread(jpanelPlayGamegame_Play_JframeplayImage.getAlImage().get(15)8080);
this.jpone=jpone;
this.jpanelPlayGame=jpanelPlayGame;
this.game_Play_Jframe=game_Play_Jframe;
//初始化加人物图片
}

@Override
public void keyPressed(KeyEvent e) {
// TODO 自动生成的方法存根
if(e.getKeyChar()==‘d‘)
{
bl=true;
//beiacctack(jsxjsh13);
if(index==4)
index=0;
jsx=jsx+5;
jpanelPlayGame.remove(jpone);
game_Play_Jframe.MoveMy(jsxjshindex);
jpanelPlayGame.repaint();
index++;
}
else if(e.getKeyChar()==‘a‘)
{
bl=false;
jsx=jsx-5;

if((10+jsx)<0)
     {
jsx=10;
jpanelPlayGame.remove(jpone);
game_Play_Jframe.MoveMy(jsxjshidexfz);
jpanelPlayGame.repaint();
}
else
{
if(idexfz==7)
idexfz=4;
jpanelPlayGame.remove(jpone);
game_Play_Jframe.MoveMy(jsxjshidexfz);
jpanelPlayGame.repaint();
idexfz++;
}
}
else if(e.getKeyChar()==‘k‘)
{

if(bl)
{
Thread t=new Thread(){
@Override
public void run()
{
for(int i=0;i<60;i++)
{
jsh-=3;
try {
Thread.sleep(5);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
jpanelPlayGame.remove(jpone);
game_Play_Jframe.MoveMy(jsxjshindex);
jpanelPlayGame.repaint();
}
}
};
t.start();
}
else
{
Thread t=new Thread(){
@Override
public void run()
{
for(int i=0;i<60;i++)
{
jsh-=3;
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
jpanelPlayGame.remove(jpone);
game_Play_Jframe.MoveMy(jsxjshidexfz);
jpanelPlayGame.repaint();
}

}
};
t.start();
}
}
else if(e.getKeyChar()==‘s‘)
{
if(bl)
{
Thread t=new Thread(){
@Override
public v

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-05-07 10:55  NamePlayGame\
     目录           0  2014-05-07 10:54  NamePlayGame\.metadata\
     文件           0  2014-05-07 10:53  NamePlayGame\.metadata\.lock
     文件      187037  2014-05-12 14:10  NamePlayGame\.metadata\.log
     目录           0  2014-05-12 14:28  NamePlayGame\.metadata\.mylyn\
     目录           0  2014-05-07 10:56  NamePlayGame\.metadata\.mylyn\.taskListIndex\
     文件          20  2014-05-07 10:56  NamePlayGame\.metadata\.mylyn\.taskListIndex\segments.gen
     文件          32  2014-05-07 10:56  NamePlayGame\.metadata\.mylyn\.taskListIndex\segments_1
     文件         254  2014-05-12 14:08  NamePlayGame\.metadata\.mylyn\.tasks.xml.zip
     目录           0  2014-05-07 10:54  NamePlayGame\.metadata\.mylyn\contexts\
     文件         447  2014-05-07 10:55  NamePlayGame\.metadata\.mylyn\repositories.xml.zip
     文件         254  2014-05-12 14:28  NamePlayGame\.metadata\.mylyn\tasks.xml.zip
     目录           0  2014-05-12 14:12  NamePlayGame\.metadata\.plugins\
     目录           0  2014-05-12 14:40  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\
     目录           0  2014-05-11 19:03  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\
     目录           0  2014-05-11 16:49  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\0\
     目录           0  2014-05-09 09:31  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\1\
     目录           0  2014-05-11 19:06  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\10\
     文件        5358  2014-05-09 16:38  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\10\20c2f15055d70013111de7cd08e6927c
     文件        6332  2014-05-11 18:21  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\10\60292506f6d800131a7df70afebf50e9
     文件        1119  2014-05-07 13:08  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\10\b06147b9a5d50013184bdb74420bf017
     文件        6329  2014-05-11 18:58  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\10\c0b0da4efcd800131a7df70afebf50e9
     文件         618  2014-05-10 10:13  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\10\d04bcb21e9d70013144ef216f478bff5
     目录           0  2014-05-11 15:56  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\11\
     文件          52  2014-05-11 15:55  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\11\20f0afb3e1d800131a7df70afebf50e9
     文件        2903  2014-05-10 14:00  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\11\708b5def08d80013144ef216f478bff5
     文件        5336  2014-05-09 16:30  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\11\d086233d54d70013111de7cd08e6927c
     目录           0  2014-05-09 16:17  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\12\
     文件        5393  2014-05-09 16:17  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\12\10dafb6952d70013111de7cd08e6927c
     文件        5397  2014-05-09 16:13  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\12\20f02be251d70013111de7cd08e6927c
     目录           0  2014-05-11 22:36  NamePlayGame\.metadata\.plugins\org.eclipse.core.resources\.history\13\
............此处省略1239个文件信息

评论

共有 条评论