开始图片
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

//存储数据

package testdata;
public class Node {private int coordX;//x坐标位置private int coordY;//y坐标位置private int dir;//方向private int speed;//速度private int atk;//攻击力private int boold;//血量private boolean isattack;//是否可以攻击private String sign;public String getSign() {return sign;}public void setSign(String sign) {this.sign = sign;}public boolean isIsattack() {return isattack;}public void setIsattack(boolean isattack) {this.isattack = isattack;}public int getDir() {return dir;}public void setDir(int dir) {this.dir = dir;}private Node next;//下一个public Node(int boold) {this.boold = boold;}public Node(int coordX, int coordY) {this.coordX = coordX;this.coordY = coordY;}/** 敌法坦克*/public Node(int coordX, int coordY, int dir, int speed, int atk, int boold) {this.coordX = coordX;this.coordY = coordY;this.dir = dir;this.speed = speed;this.atk = atk;this.boold = boold;}public Node(int coordX, int coordY, int speed, int atk, int boold, boolean isattack, Node next) {this.coordX = coordX;this.coordY = coordY;this.speed = speed;this.atk = atk;this.boold = boold;this.isattack = isattack;this.next = next;}//土砖public Node(int coordX, int coordY, int boold) {this.coordX = coordX;this.coordY = coordY;this.boold = boold;}//石砖public Node(int coordX, int coordY, int boold, boolean isattack) {this.coordX = coordX;this.coordY = coordY;this.boold = boold;this.isattack = isattack;}//子弹---public Node(int coordX, int coordY, int speed, int atk,int dir) {this.coordX = coordX;this.coordY = coordY;this.speed = speed;this.atk = atk;this.dir=dir;}public void setSpeed(int speed) {this.speed = speed;}public void setAtk(int atk) {this.atk = atk;}public void setBoold(int boold) {this.boold = boold;}public int getSpeed() {return speed;}public int getAtk() {return atk;}public int getBoold() {return boold;}public int getCoordX() {return coordX;}public int getCoordY() {return coordY;}public void setCoordX(int coordX) {this.coordX = coordX;}public void setCoordY(int coordY) {this.coordY = coordY;}public Node getNext(){return next;}public void setNext(Node next){this.next=next;}public void display(){System.out.println("[ "+coordX+", "+coordY+" ]");}
}

//链表

package testdata;	public class SLinkList {private Node head;//表头private int length;//表的长度public SLinkList(){head=null;}/** 表头添加结点*/public void addHead(Node newNode){if(head == null){head=newNode;} else {newNode.setNext(head);head=newNode;}length++;}/** 删除表头结点*/public void delHead(){if(head==null){return ;}Node curNode = head;head=curNode.getNext();length--;}/** 表尾添加结点*/public void addTail(Node newNode){//坐标位置,已经有的长度if(head==null){head=newNode;}else{int count=1;Node tailNode = head;while(count<length){tailNode=tailNode.getNext();count++;}Node curNode = tailNode.getNext();newNode.setNext(curNode);tailNode.setNext(newNode);}length++;}/** 删除表尾结点*/public void delTail() {//坐标位置,已经有的长度if (head == null) {return ;}int count = 1;Node tailNode = head;while (count < length - 1) {tailNode = tailNode.getNext();count++;}Node curNode = tailNode.getNext();tailNode.setNext(curNode.getNext());length--;}/** 指定位置删除*/public void delIndex(int index) {if(index > length || index < 1) {System.out.println("结点删除的位置不存在,可删除的位置为1到"+length);}else if(index == 1) {     //删除表头结点Node curNode = head;head = curNode.getNext();length--;return ;}else{         //删除链表中间或尾部结点Node preNode = head;int count = 1;while(count < index-1) {preNode = preNode.getNext();count++;}Node curNode = preNode.getNext();preNode.setNext(curNode.getNext());length--;return ;}}/** 显示链表中的结点数据*/public void display(){if(head==null){System.out.println("没有数据");return;}int count=1;Node node = head;while(count<=length){node.display();node = node.getNext();count++;}}/** 更改是否可攻击*/public void setarg(int index,boolean isattack){int count=1;Node node = head;if(head==null){return;}else {while(count<index){node = node.getNext();count++;}node.setIsattack(isattack);}}/** 更改所有的参数*/public void setarg(int index,int x,int y,int speed,int atk,int blood,int dir){int count=1;Node node = head;if(head==null){return;}else {while(count<index){node = node.getNext();count++;}node.setCoordX(x);node.setCoordY(y);node.setSpeed(speed);node.setAtk(atk);node.setBoold(blood);node.setDir(dir);}}/**更改单个参数*/public void setarg(int index,int number,String str){int count=1;Node node = head;if(head==null){return;}else {while(count<index){node = node.getNext();count++;}if(str.equals("coordX"))node.setCoordX(number);else if(str.equals("coordY"))node.setCoordY(number);else if(str.equals("speed"))node.setSpeed(number);else if(str.equals("atk"))node.setAtk(number);else if(str.equals("blood"))node.setBoold(number);else if(str.equals("dir"))node.setDir(number);}}/** 更改位置*/public void setarg(int index,int x,int y){int count=1;Node node = head;if(head==null){return;}else {while(count<index){node = node.getNext();count++;}node.setCoordX(x);node.setCoordY(y);}}/** 更改子弹参数*/public void setarg(int index,int x,int y,int speed,int atk,int dir){int count=1;Node node = head;if(head==null){return;}else {while(count<index){node = node.getNext();count++;}node.setCoordX(x);node.setCoordY(y);node.setSpeed(speed);node.setAtk(atk);node.setDir(dir);}}/** 更改老鹰参数*/public void setarg(int index ,int blood){int count=1;Node node = head;if(head==null){return;}else {while(count<index){node = node.getNext();count++;}node .setBoold(blood);node.setIsattack(true);}}/** 更改土砖参数*/public void setarg(int index,int x,int y,int blood){int count=1;Node node = head;if(head==null){return;}else {while(count<index){node = node.getNext();count++;}node.setCoordX(x);node.setCoordY(y);node.setBoold(blood);node.setIsattack(true);}}/** 更改石砖参数*/public void setarg(int index,int x,int y,boolean isattack){int count=1;Node node = head;if(head==null){return;}else {while(count<index){node = node.getNext();count++;}node.setCoordX(x);node.setCoordY(y);node.setIsattack(false);}}/** 获得想要的参数*/public int getarg(int index,String str) {int count = 1;Node node = head;if (head == null) {return 0;}while (count < index) {node = node.getNext();count++;}if(str.equals("coordX")){return node.getCoordX();}else if(str.equals("coordY"))return node.getCoordY();else if(str.equals("speed"))return node.getSpeed();else if(str.equals("atk"))return node.getAtk();else if(str.equals("blood"))return node.getBoold();elsereturn node.getDir();}public String getSign(int index){int count = 1;Node node = head;if (head == null) {return null;}while (count < index) {node = node.getNext();count++;}return node.getSign();}/** 返回表的长度*/public int getLength(){return length;}
}

//地图

package tank_game;
import testdata.SLinkList;import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;public class drawMap extends SLinkList implements KeyListener {ImageIcon tuzhuan = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\tuzhuan.png");ImageIcon shizhuan = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\shizhuan.png");ImageIcon laoying = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\laoying.png");ImageIcon explode2=new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\explode2.png");ImageIcon explode1 = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\explode1.png");ImageIcon cao = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\cao.png");ImageIcon shui = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\shui.png");ImageIcon gameover = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\gameover.png");public drawMap(){/*    if(type == 1 ){//老鹰setarg(375,700,1);}else if(type == 2){//土砖}else if(type == 3){//石砖}else if(type ==4 ){//大爆炸}*/}public void drawmap(int type,JFrame frame, Graphics g,int x,int y){if(type == 1){//画老鹰laoying.paintIcon(frame,g,x,y);}else if(type ==2 ){//画土砖tuzhuan.paintIcon(frame,g,x,y);}else if(type == 3) {//画石砖shizhuan.paintIcon(frame,g,x,y);}else if(type ==4 ){//画大爆炸explode2.paintIcon(frame,g,x,y);}else if(type == 5){//画小爆炸explode1.paintIcon(frame,g,x,y);}else if(type == 6){//画草丛cao.paintIcon(frame,g,x,y);}else if(type == 7){//画水shui.paintIcon(frame,g,x,y);}else if(type == 8) {//游戏结束gameover.paintIcon(frame,g,x,y);}}@Overridepublic void keyTyped(KeyEvent e) {}@Overridepublic void keyPressed(KeyEvent e) {}@Overridepublic void keyReleased(KeyEvent e) {}
}

//己方
//子弹

package tank_game;import testdata.SLinkList;import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;public class myButtet extends SLinkList implements KeyListener {ImageIcon bullet = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\playerBullet.png");public myButtet(){ }@Overridepublic void keyTyped(KeyEvent e) { }@Overridepublic void keyPressed(KeyEvent e) { }@Overridepublic void keyReleased(KeyEvent e) { }/** 画子弹*/public void drawBullet(Frame frame,Graphics g, int x, int y){bullet.paintIcon(frame,g,x,y);}
}

//坦克
package tank_game;

import testdata.SLinkList;import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;public class myTank extends SLinkList implements KeyListener {int score;int life;ImageIcon up = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\playerUp.png");ImageIcon down = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\playerDown.png");ImageIcon right = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\playerRight.png");ImageIcon left = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\playerLeft.png");ImageIcon boom1 = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\explode1.png");ImageIcon boom2 = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\explode2.png");public int getScore() {return score;}public void setScore(int score) {this.score = score;}public int getLife() {return life;}public void setLife(int life) {this.life = life;}public myTank(){score = 0;life = 5;}public void drawTank(JFrame frame,Graphics g,int x,int y,int dir){//设置坦克位置switch(dir){case 1://上up.paintIcon(frame,g,x,y);break;case 2://下down.paintIcon(frame,g,x,y);break;case 3://左left.paintIcon(frame,g,x,y);break;case 4://右right.paintIcon(frame,g,x,y);break;}}public void drawBom1(Frame frame,Graphics g,int x,int y){boom1.paintIcon(frame,g,x,y);}public void drawBom2(Frame frame,Graphics g,int x,int y){boom2.paintIcon(frame,g,x,y);}@Overridepublic void keyTyped(KeyEvent e) {}@Overridepublic void keyPressed(KeyEvent e) {}@Overridepublic void keyReleased(KeyEvent e) {}
}

//敌方
//子弹
package tank_game;
import testdata.SLinkList;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;public class enemyButtet extends SLinkList implements KeyListener {ImageIcon bullet = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\enemyBullet.png");public enemyButtet(){}@Overridepublic void keyTyped(KeyEvent e) { }@Overridepublic void keyPressed(KeyEvent e) { }@Overridepublic void keyReleased(KeyEvent e) { }/** 画子弹*/public void drawBullet(Frame frame, Graphics g, int x, int y){bullet.paintIcon(frame,g,x,y);}}

//坦克

package tank_game;import testdata.SLinkList;import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;public class enemyTank extends SLinkList implements KeyListener {int step;ImageIcon  Eup = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\EtankUp.png");ImageIcon Edown = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\EtankDown.png");ImageIcon Eleft = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\EtankLeft.png");ImageIcon Eright = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\EtankRight.png");ImageIcon Eboom1 = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\explode1.png");ImageIcon Eboom2 = new ImageIcon("E:\\张wp.c\\Eclipse Java\\tank\\.con\\res\\explode2.png");public int getStep() {return step;}public void setStep(int step) {this.step = step;}public enemyTank(){this.step = 4;}public void drawTank(int dir, Frame frame,Graphics g,int x,int y){switch (dir){//上下左右case 1:Eup.paintIcon(frame,g,x,y);break;case 2:Edown.paintIcon(frame,g,x,y);break;case 3:Eleft.paintIcon(frame,g,x,y);break;case 4:Eright.paintIcon(frame,g,x,y);break;}}public void drawBom1(Frame frame,Graphics g,int x,int y){Eboom1.paintIcon(frame,g,x,y);}public void drawBom2(Frame frame,Graphics g,int x,int y){Eboom2.paintIcon(frame,g,x,y);}@Overridepublic void keyTyped(KeyEvent e) {}@Overridepublic void keyPressed(KeyEvent e) {}@Overridepublic void keyReleased(KeyEvent e) {}
}

//行动

package tank_game;
import testdata.Node;
import javax.swing.*;
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.net.URI;
import java.net.URL;
import java.util.Random;public class action extends JFrame  implements KeyListener , ActionListener, MouseListener {static File f1 =new File("E:\\张wp.c\\Eclipse Java\\tank\\.con\\sound\\boom.wav");static File f2 = new File("E:\\张wp.c\\Eclipse Java\\tank\\.con\\sound\\tankPK.wav");int enemyTanks;//敌方坦克数量int useTanks;//添加的坦克数量JButton again;myTank player1;myTank player2;myButtet zidan;enemyTank Etanks;//敌方坦克enemyButtet Ezidan;//敌方子弹drawMap laoying;drawMap tuzhuan;drawMap shizhuan;drawMap caocong;drawMap shui;//游戏是否结束boolean isExist;//是否胜利boolean isWin;//是否爆炸boolean isBom;//Timer timer = new Timer(100, this);//播放音乐AudioClip clip;AudioClip bom;//击中后爆炸声public action() {this.setSize(800, 800);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setResizable(false);this.setTitle("坦克大战");this.getContentPane().setBackground(Color.BLACK);this.setFocusable(true);this.addKeyListener(this);init();this.setVisible(true);//这个一般放在最后显示窗口  --- 不然出现为null现象}public void addtanks(){Node node = null;if(useTanks==0){if(enemyTanks>4) {for (int i = 0; i < 4; i++) {node = new Node(175 + i * 150, 100+64, 2, 10, 50, 150);Etanks.addTail(node);useTanks++;}useTanks+=4;}else if(enemyTanks>0){for (int i = 0; i < enemyTanks; i++) {node = new Node(175 + i * 150, 100+64, 2, 10, 50, 150);Etanks.addTail(node);useTanks++;}useTanks+=enemyTanks;}else{isWin=true;}}}public void init() {//布局setLayout(null);//敌方坦克数量enemyTanks = 20;useTanks=0;//游戏是否结束isExist = false;isWin = false;isBom = false;/** 坦克*/player1 = new myTank();player2 = new myTank();//画子弹zidan = new myButtet();//初始化地方坦克数据Etanks = new enemyTank();//画子弹Ezidan = new enemyButtet();/** 画地图*///画老鹰laoying = new drawMap();//画土砖tuzhuan = new drawMap();//画石砖shizhuan = new drawMap();//画草丛caocong = new drawMap();//画水shui = new drawMap();//地图初始化initMap();//敌人初始化inittanks();//时间开始//重新开始again = new JButton();again.setFont(new Font("宋体",1,30));again.setText("重新开始");again.setBackground(Color.orange);again.setBounds(285,705,200,50);again.addMouseListener(this);this.add(again);//音乐loadSound();clip.loop();//循环播放playBom();timer.start();}/** 初始化坦克数据*/public void inittanks() {Node node;/** 我方坦克*/node = new Node(200, 600, 1, 20, 20, 100);player1.addTail(node);node = new Node(600, 600, 1, 20, 20, 100);player2.addTail(node);//敌方坦克/* for (int i = 1; i <= enemyTanks; i++) {node = new Node(int coordX, int coordY, int dir, int speed, int atk, int boold)}*/for (int i = 0; i < 4; i++) {node = new Node(175 + i * 150, 100+64, 2, 10, 10, 150);Etanks.addTail(node);useTanks++;}}/**初始化地图数据 */public void initMap() {Node node;//老鹰初始化数据node = new Node(1);laoying.addHead(node);//土砖初始化----int nx = 391 - 32;int ny = 716 - 32;int x = nx, y = ny;/** 基地土砖*/for (int i = 0; i < 2; i++) {x = nx;y += 32 * i;for (int j = 0; j < 3; j++) {if (x == 391 && y == 716) {System.out.println("跳过");} else {node = new Node(x, y, 100);tuzhuan.addTail(node);}x += 32;}}/** 外部土砖*/for (int i = 0; i < 5; i++) {for (int j = 0; j <6; j++) {node = new Node(100+150*i,120+32*j,100);tuzhuan.addTail(node);}node = new Node(100+150*i,120+32*6,100,false);shizhuan.addTail(node);}//石砖初始化for (int i = 0; i <= 3; i++) {node = new Node(120 + i * 32 - 32, 500 , 100, false);shizhuan.addTail(node);}for (int i = 0; i <=3 ; i++) {node = new Node(600+i*32,500,100,false);shizhuan.addTail(node);}for (int i = 0; i < 5; i++) {node = new Node(nx+i*32-32,ny-32-32,100,false);shizhuan.addTail(node);}//草丛初始化for (int i = 1; i <= 20; i++) {for (int j = 1; j < 3; j++) {node = new Node(120-64+i*32, 400 + j * 32);caocong.addTail(node);}}/** 水初始化*/for (int i = 0; i < 10; i++) {node = new Node(120+i*32+32*4,500);shui.addTail(node);}}/** 敌方坦克移动* */public void Move() {Random random  = new Random();Node node = null;int len;for (int i = 1; i <= Etanks.getLength(); i++) {/** 获取移动方向* */int moveDir = random.nextInt(13) + 1;//1-4 上下左右int x = Etanks.getarg(i, "coordX");int y = Etanks.getarg(i, "coordY");int speed = Etanks.getarg(i, "speed");int dir = Etanks.getarg(i, "dir");int atk = Etanks.getarg(i, "atk");int step = Etanks.getStep();//返回最大前进步数//375  700if (y < 500) {//向下,向左 , 向右moveDir = random.nextInt(10) + 3;}len = tankMove("enemy", x, y, dir, speed, i);if (step > 0) {step--;switch (dir) {case 1:if (y > 120) {if (len != -1) {y -= len;} else {y -= speed;}}break;case 2:if (y < 705) {if (len != -1) {y += len;} else {y += speed;}}break;case 3:if (x > 75) {if (len != -1) {x -= len;} else {x -= speed;}}break;case 4:if (x < 728) {if (len != -1) {x += len;} else {x += speed;}}}} else {step = 4;switch (moveDir) {case 1:case 2:dir = 1;break;case 8:case 5:case 6:dir = 2;break;case 3:case 9:case 10:dir = 3;break;case 4:case 7:case 11:dir = 4;break;}}if (moveDir == 12) {switch (dir) {case 2://上node = new Node(x, y + 14 + 5, speed, atk, dir);break;case 1://下node = new Node(x, y - 14 - 5, speed, atk, dir);break;case 3://左node = new Node(x - 14 - 5, y, speed, atk, dir);break;case 4://右node = new Node(x + 14 + 5, y, speed, atk, dir);break;}Ezidan.addTail(node);}/** 重新设置位置*/Etanks.setarg(i, x, y);/** 重新设置方向*/Etanks.setarg(i, dir, "dir");/** 重新设置步数*/Etanks.setStep(step);}}/** 坦克移动相差距离*/public int tankMove(String str,int tankX,int tankY,int dir,int speed ,int temp){int len = -1;int oldlen = -1;int x,y;/** 石砖*/for (int i = 1; i <= shizhuan.getLength(); i++) {x = shizhuan.getarg(i,"coordX");;y = shizhuan.getarg(i,"coordY");len = tankMoveJudge(tankX,tankY,dir,speed,x,y);if(len!=-1){if(oldlen==-1){oldlen=len;}else{oldlen=Math.min(oldlen,len);}}}/** 老鹰*/x = laoying.getarg(1,"coordX");y = laoying.getarg(1,"coordY");len = tankMoveJudge(tankX,tankY,dir,speed,x,y);if(len!=-1) {if (oldlen == -1) {oldlen = len;} else {oldlen = Math.min(oldlen, len);}}/** 土砖*/for (int i = 1; i <= tuzhuan.getLength(); i++) {x = tuzhuan.getarg(i, "coordX");y = tuzhuan.getarg(i, "coordY");len = tankMoveJudge(tankX, tankY, dir, speed, x, y);if (len != -1) {if (oldlen == -1) {oldlen = len;} else {oldlen = Math.min(oldlen, len);}}}/** 水*/for (int i = 1; i <= shui.getLength(); i++) {x = shui.getarg(i,"coordX");y = shui.getarg(i,"coordY");;len = tankMoveJudge(tankX,tankY,dir,speed,x,y);if(len!=-1){if(oldlen==-1){oldlen=len;}else{oldlen=Math.min(oldlen,len);}}}//p1for (int i = 1; i <= player1.getLength(); i++) {if (i == temp && str.equals("m1"))continue;x = player1.getarg(i, "coordX");y = player1.getarg(i, "coordY");len = tankMoveJudge(tankX, tankY, dir, speed, x, y);;if (len != -1) {if (oldlen == -1) {oldlen = len;} else {oldlen = Math.min(oldlen, len);}}}//p2for (int i = 1; i <= player2.getLength(); i++) {if(i==temp&&str.equals("m2"))continue;x = player2.getarg(i,"coordX");y = player2.getarg(i,"coordY");len = tankMoveJudge(tankX,tankY,dir,speed,x,y);if(len!=-1){if(oldlen==-1){oldlen=len;}else{oldlen=Math.min(oldlen,len);}}}//Etanksfor (int i = 1; i <= Etanks.getLength(); i++) {if (i == temp && str.equals("enemy"))continue;x = Etanks.getarg(i, "coordX");y = Etanks.getarg(i, "coordY");;len = tankMoveJudge(tankX, tankY, dir, speed, x, y);;if (len != -1) {if (oldlen == -1) {oldlen = len;} else {oldlen = Math.min(oldlen, len);}}}if(oldlen!=-1){return oldlen;}return -1;}/** 坦克移动距离判断*/public int tankMoveJudge(int tankX,int tankY,int dir,int speed,int x,int y){int  tx = tankX;int  ty = tankY;int len2,len3,len1,len = -1;if(dir == 1){ty -= speed;}else if(dir == 2){ty += speed;}else if(dir == 3){tx -= speed;}else if(dir == 4){tx += speed;}len2 = tx -x;len3 = ty -y;len1 = (int)Math.sqrt(len2*len2+len3*len3);if(len1<42){//最大移动距离if(dir == 1) {len = Math.abs((tankY - 14) - (y + 16));}else if(dir == 2) {len = Math.abs((tankY + 14) - (y - 16));}else if(dir ==3) {len = Math.abs((tankX - 14) - (x + 16));}else if(dir == 4){len = Math.abs((tankX + 14) - (x - 16));}if(len == 0) {if(len1<30){return 0;}else{return -1;}}if(len<speed)return len;}return -1;}/** 己方子弹*/public void myBulletsMove(){for (int i = 1; i <= zidan.getLength(); i++) {//子弹存储的是中心坐标int x = zidan.getarg(i,"coordX");int y = zidan.getarg(i,"coordY");int Dir = zidan.getarg(i,"dir");int speed = zidan.getarg(i,"speed");switch (Dir){case 1://上zidan.setarg(i, y-speed,"coordY");break;case 2://下zidan.setarg(i,y+speed,"coordY");break;case 3://左zidan.setarg(i, x-speed, "coordX");break;case 4://右zidan.setarg(i, x+speed, "coordX");break;}}for (int i = 1; i <= zidan.getLength(); i++) {if(zidan.getarg(i,"coordX")<40-5||zidan.getarg(i,"coordY")<90-5||zidan.getarg(i,"coordX")>10+750-5||zidan.getarg(i,"coordY")>742-5){zidan.delIndex(i);}}}/** 发射子弹*/public void shoot(int dir,int tankX,int tankY,int speed,int atk,String sign){Node node = null;switch (dir){case 1://上node = new Node(tankX,tankY- 14 - 5 ,speed,atk,dir);break;case 2://下node = new Node(tankX,tankY + 14 + 5,speed,atk,dir);break;case 3://左node = new Node(tankX-14-5,tankY,speed,atk,dir);break;case 4://右node = new Node(tankX+14+5,tankY,speed,atk,dir);break;}node.setSign(sign);zidan.addTail(node);}/** 敌方子弹*/public void enemyBulletsMove(){for (int i = 1; i <= Ezidan.getLength(); i++) {//子弹存储的是中心坐标int x = Ezidan.getarg(i,"coordX");int y = Ezidan.getarg(i,"coordY");int Dir = Ezidan.getarg(i,"dir");int speed = Ezidan.getarg(i,"speed");switch (Dir){case 1://上Ezidan.setarg(i, y-speed,"coordY");break;case 2://下Ezidan.setarg(i,y+speed,"coordY");break;case 3://左Ezidan.setarg(i, x-speed, "coordX");break;case 4://右Ezidan.setarg(i, x+speed, "coordX");break;}}for (int i = 1; i <= Ezidan.getLength(); i++) {if(Ezidan.getarg(i,"coordX")<40-5||Ezidan.getarg(i,"coordY")<90-5||Ezidan.getarg(i,"coordX")>10+750-5||Ezidan.getarg(i,"coordY")>742-5){Ezidan.delIndex(i);}}}Image offScreenImage = null;/** 己方攻击*/public void attack(Graphics g) {/** 子弹*/for (int i = 1; i <= zidan.getLength(); i++) {int x = zidan.getarg(i, "coordX");int y = zidan.getarg(i, "coordY");int atk = zidan.getarg(i,"atk");String sign = zidan.getSign(i);//两个中心之间相差两个矩形半径之和则相交--命中/** 老鹰坐标*/int lx = (375 + 375 + 32) / 2;int ly = (700 * 2 + 32) / 2;if (Math.sqrt((lx - x) * (lx - x) + (ly - y) * (ly - y)) < 5 + 16 && laoying.getarg(1, "blood") > 0) {isBom=true;//画爆炸laoying.drawmap(4, this, g, 359, 668);//子弹消失zidan.delIndex(i);//老鹰消失laoying.setarg(1, 0);isExist = true;}/** 土砖被击中*/for (int j = 1; j <= tuzhuan.getLength(); j++) {int tx = tuzhuan.getarg(j, "coordX");int ty = tuzhuan.getarg(j, "coordY");if (Math.sqrt((tx - x) * (tx - x) + (ty - y) * (ty - y)) < 5 + 16 && tuzhuan.getarg(j, "blood") > 0) {isBom=true;//子弹消失zidan.delIndex(i);//爆炸tuzhuan.drawmap(5, this, g, tx - 16, ty - 16);//被攻击掉血int blood = tuzhuan.getarg(j, "blood") - atk;System.out.println(blood);if (blood > 0) {tuzhuan.setarg(j, blood);} else {//删掉tuzhuan.delIndex(j);}break;}}/** 石砖被攻击*/for (int j = 1; j <= shizhuan.getLength(); j++) {int sx = shizhuan.getarg(j, "coordX");int sy = shizhuan.getarg(j, "coordY");if (Math.sqrt((sx - x) * (sx - x) + (sy - y) * (sy - y)) < 5 + 16 && shizhuan.getarg(j, "blood") > 0) {isBom=true;zidan.delIndex(i);shizhuan.drawmap(5, this, g, shizhuan.getarg(j, "coordX") - 14, shizhuan.getarg(j, "coordY") - 14);break;}}/** 敌方坦克被攻击*/for (int j = 1; j <= Etanks.getLength() ; j++) {int ex = Etanks.getarg(j,"coordX");int ey = Etanks.getarg(j,"coordY");if (Math.sqrt((ex - x) * (ex - x) + (ey - y) * (ey - y)) < 5 + 14 && Etanks.getarg(j, "blood") > 0) {isBom=true;//子弹消失zidan.delIndex(i);//爆炸Etanks.drawBom1( this, g, ex - 14, ey - 14);//被攻击掉血int blood = Etanks.getarg(j, "blood") - atk;System.out.println(blood);if (blood > 0) {Etanks.setarg(j, blood);} else {Etanks.drawBom2( this, g, ex - 14, ey - 14);//删掉//击败得分if(sign == "p1"){player1.setScore(player1.getScore()+20);}else{player2.setScore(player2.getScore()+20);}Etanks.delIndex(j);enemyTanks--;useTanks--;}break;}}}}/** 敌方攻击*/public void Eattack(Graphics g){/** 子弹*/for (int i = 1; i <= Ezidan.getLength(); i++) {int x = Ezidan.getarg(i, "coordX");int y = Ezidan.getarg(i, "coordY");int atk = Ezidan.getarg(i,"atk");//两个中心之间相差两个矩形半径之和则相交--命中/** 老鹰坐标*/int lx = (375 + 375 + 32) / 2;int ly = (700 * 2 + 32) / 2;if (Math.sqrt((lx - x) * (lx - x) + (ly - y) * (ly - y)) < 5 + 16 && laoying.getarg(1, "blood") > 0) {//isBom=true;//画爆炸laoying.drawmap(4, this, g, 359, 668);//子弹消失zidan.delIndex(i);//老鹰消失laoying.setarg(1, 0);;isExist = true;break;}/** 土砖被击中*/for (int j = 1; j <= tuzhuan.getLength(); j++) {int tx = tuzhuan.getarg(j, "coordX");int ty = tuzhuan.getarg(j, "coordY");if (Math.sqrt((tx - x) * (tx - x) + (ty - y) * (ty - y)) < 5 + 16 && tuzhuan.getarg(j, "blood") > 0) {//子弹消失// isBom=true;//爆炸tuzhuan.drawmap(5, this, g, tx - 16, ty - 16);//被攻击掉血int blood = tuzhuan.getarg(j, "blood") - atk;//System.out.println(blood);if (blood > 0) {tuzhuan.setarg(j, blood);} else {//删掉tuzhuan.delIndex(j);}Ezidan.delIndex(i);break;}}/** 石砖被攻击*/for (int j = 1; j <= shizhuan.getLength(); j++) {int sx = shizhuan.getarg(j, "coordX");int sy = shizhuan.getarg(j, "coordY");if (Math.sqrt((sx - x) * (sx - x) + (sy - y) * (sy - y)) < 5 + 16 && shizhuan.getarg(j, "blood") > 0) {// isBom=true;Ezidan.delIndex(i);shizhuan.drawmap(5, this, g, shizhuan.getarg(j, "coordX") - 14, shizhuan.getarg(j, "coordY") - 14);break;}}/** 己方坦克被攻击*/for (int j = 1; j <= player1.getLength() ; j++) {int ex = player1.getarg(j,"coordX");int ey = player1.getarg(j,"coordY");
;if (Math.sqrt((ex - x) * (ex - x) + (ey - y) * (ey - y)) < 5 + 14 && player1.getarg(j, "blood") > 0) {//  isBom=true;//子弹消失Ezidan.delIndex(i);//爆炸player1.drawBom1( this, g, ex - 14, ey - 14);//被攻击掉血int blood = player1.getarg(j, "blood") - atk;//System.out.println(blood);if (blood > 0) {player1.setarg(j, blood);} else {player1.drawBom2( this, g, ex - 14, ey - 14);//删掉if(player1.getLife() == 0)player1.delIndex(j);else{player1.setLife(player1.getLife()-1);player1.setarg(j,100,"blood");player1.setarg(j,200,600);}}break;}}for (int j = 1; j <= player2.getLength() ; j++) {int ex = player2.getarg(j,"coordX");int ey = player2.getarg(j,"coordY");if (Math.sqrt((ex - x) * (ex - x) + (ey - y) * (ey - y)) < 5 + 14 && player2.getarg(j, "blood") > 0) {//  isBom=true;//子弹消失Ezidan.delIndex(i);//爆炸player2.drawBom1( this, g, ex - 14, ey - 14);//被攻击掉血int blood = player2.getarg(j, "blood") - atk;//System.out.println(blood);if (blood > 0) {player2.setarg(j, blood);} else {player2.drawBom2( this, g, ex - 14, ey - 14);//删掉if(player2.getLife() == 0)player2.delIndex(j);else{player2.setLife(player2.getLife()-1);;player2.setarg(j,100,"blood");player2.setarg(j,600,600);}}break;}}}}public void Tmove(int keyCode){int len = 0;/** player1*/for (int i = 1; i <= player1.getLength() ; i++) {int dir =player1.getarg(i,"dir");int tankX = player1.getarg(i,"coordX");int tankY = player1.getarg(i,"coordY");int speed = player1.getarg(i,"speed");int atk =player1.getarg(i,"atk");//返回最大前进步数len = tankMove("m1",tankX,tankY,dir,speed,i);if(keyCode=='w'||keyCode=='W'){if((dir!=1||(dir==1&&tankY<100+20))){dir=1;}else if(len!=-1){tankY -= len;}else{tankY -=speed;}} else if(keyCode == 's'|| keyCode == 'S'){if((dir!=2||(tankY>700+4&&dir==2))){dir=2;}else if(len!=-1){tankY += len;}else{tankY +=speed;}}else if(keyCode =='a' || keyCode =='A'){if(dir!=3||(dir==3&&tankX<50+25)){dir=3;}else if(len!=-1){tankX -= len;}else{tankX-=speed;}}else if(keyCode =='d' || keyCode == 'D'){if(dir!=4||(dir==4&&tankX>728)){dir=4;}else if(len!=-1){tankX += len;}else{tankX +=speed;}}player1.setarg(i,tankX,tankY,speed,atk,dir);if(keyCode == KeyEvent.VK_SPACE|| keyCode == 'j'|| keyCode == 'J'){shoot(dir,tankX,tankY,speed,atk,"p1");}}/** player2*/for (int i = 1; i <= player2.getLength() ; i++) {int dir =player2.getarg(i,"dir");int tankX = player2.getarg(i,"coordX");int tankY = player2.getarg(i,"coordY");int speed = player2.getarg(i,"speed");int atk =player2.getarg(i,"atk");//返回最大前进步数len = tankMove("m2",tankX,tankY,dir,speed,i);if(keyCode == KeyEvent.VK_UP){if((dir!=1||(dir==1&&tankY<100+20))){dir=1;}else if(len!=-1){tankY -= len;}else{tankY -= speed;}} else if(keyCode == KeyEvent.VK_DOWN){if((dir!=2||(tankY>700+4&&dir==2))){dir=2;}else if(len!=-1){tankY+=len;}else{tankY+=speed;}}else if(keyCode == KeyEvent.VK_LEFT){if(dir!=3||(dir==3&&tankX<50+25)){dir=3;}else if(len!=-1){tankX-=len;}else{tankX-=speed;}}else if(keyCode == KeyEvent.VK_RIGHT){if(dir!=4||(dir==4&&tankX>728)){dir=4;}else if(len!=-1){tankX+=len;}else{tankX+=speed;}}player2.setarg(i,tankX,tankY,speed,atk,dir);if(keyCode == 96){shoot(dir,tankX,tankY,speed,atk,"p2");}}}/** 播放总音乐*/public void loadSound(){try {URI uri = f2.toURI();URL url = uri.toURL();clip= Applet.newAudioClip(url);}catch (Exception e){}}/** 爆炸声*/public void playBom(){try {URI uri = f1.toURI();URL url = uri.toURL();bom= Applet.newAudioClip(url);}catch (Exception e){}}@Overridepublic void update(Graphics g) {//1.得到缓冲图象if(this.offScreenImage==null){this.offScreenImage = this.createImage(800,800);}//2.得到缓冲图象的画笔Graphics gOffScreen = this.offScreenImage.getGraphics();//3.绘制缓冲图象Color c = gOffScreen.getColor();gOffScreen.setColor(Color.black);gOffScreen.fillRect(0, 0, 800,800);gOffScreen.setColor(c);//4.调用paint(),将缓冲图象的画笔传入paint(gOffScreen);//5.再将此缓冲图像一次性绘到代表屏幕的Graphics对象,即该方法传入的“g”上g.drawImage(offScreenImage, 0, 0, null);}@Overridepublic void paint(Graphics g){if(isExist){laoying.drawmap(8,this,g,275,350);return;}super.paint(g);//己方坦克//p1for (int i = 1; i <= player1.getLength() ; i++) {int x = player1.getarg(i,"coordX");int y =player1.getarg(i,"coordY");int dir = player1.getarg(i,"dir");player1.drawTank(this,g,x-14,y-14,dir);}//p2for (int i = 1; i <= player2.getLength() ; i++) {int x = player2.getarg(i,"coordX");int y =player2.getarg(i,"coordY");int dir = player2.getarg(i,"dir");player2.drawTank(this,g,x-14,y-14,dir);;}//画水for (int i = 1; i <= shui.getLength() ; i++) {int x = shui.getarg(i,"coordX");int y =shui.getarg(i,"coordY");shui.drawmap(7,this,g,x-16,y-16);}//己方子弹for (int i = 1; i <= zidan.getLength(); i++) {int x=zidan.getarg(i,"coordX");int y=zidan.getarg(i,"coordY");zidan.drawBullet(this,g,x-5,y-5);}//己方老鹰if(laoying.getarg(0,"blood")==1)laoying.drawmap(1,this,g,375,700);//画地图//画土砖for (int i = 1; i <= tuzhuan.getLength(); i++) {int x= tuzhuan.getarg(i,"coordX");int y= tuzhuan.getarg(i,"coordY");int blood = tuzhuan.getarg(i,"blood");if(blood>0){tuzhuan.drawmap(2,this,g,x-16,y-16);}}//画石砖for (int i = 1; i <= shizhuan.getLength() ; i++) {int x= shizhuan.getarg(i,"coordX");int y= shizhuan.getarg(i,"coordY");int blood = shizhuan.getarg(i,"blood");if(blood>0){shizhuan.drawmap(3,this,g,x-16,y-16);}}/** 敌人** *//** 敌方坦克*/for (int i = 1; i <= Etanks.getLength(); i++) {int x = Etanks.getarg(i,"coordX");int y = Etanks.getarg(i,"coordY");int blood = Etanks.getarg(i,"blood");int dir = Etanks.getarg(i,"dir");if(blood>0){Etanks.drawTank(dir,this,g,x-14,y-14);}}/** 敌方子弹*/for (int i = 1; i <= Ezidan.getLength(); i++) {int x=Ezidan.getarg(i,"coordX");int y=Ezidan.getarg(i,"coordY");Ezidan.drawBullet(this,g,x-5,y-5);}//画草丛for (int i = 1; i <= caocong.getLength() ; i++) {int x= caocong.getarg(i,"coordX");int y= caocong.getarg(i,"coordY");caocong.drawmap(6,this,g,x-16,y-16);}//攻击后变化attack(g);Eattack(g);//限制地图g.setColor(Color.ORANGE);g.setFont(new Font("宋体",1,30));g.drawLine(50,100,750,100);g.drawLine(50,732,750,732);g.drawLine(50,100,50,732);g.drawLine(750,100,750,732);/** 画分数*/g.drawString("p1 score:"+player1.getScore(),100,60);g.drawString("p2 score:"+player2.getScore(),450,60);/** 画生命*/g.drawString("p1 life:"+player1.getLife(),100,90);g.drawString("p2 life:"+player2.getLife(),450,90);}@Overridepublic void keyTyped(KeyEvent e) {int keyCode = e.getKeyCode();}@Overridepublic void keyPressed(KeyEvent e) {int keyCode = e.getKeyCode();}@Overridepublic void keyReleased(KeyEvent e) {int keyCode = e.getKeyCode();Tmove(keyCode);}@Overridepublic void actionPerformed(ActionEvent e) {if(!isExist) {enemyBulletsMove();myBulletsMove();Move();if(isBom){isBom=false;bom.play();}if(!isWin){addtanks();//胜利}else if(useTanks == 0){JOptionPane.showConfirmDialog(null,"胜利了",null,JOptionPane.OK_OPTION);isWin=false;useTanks=1;}}else{clip.stop();bom.stop();}repaint();}@Overridepublic void mouseClicked(MouseEvent e) {}@Overridepublic void mousePressed(MouseEvent e) {}@Overridepublic void mouseReleased(MouseEvent e) {dispose();clip.stop();bom.stop();new action();}@Overridepublic void mouseEntered(MouseEvent e) {}@Overridepublic void mouseExited(MouseEvent e) {}
}

//主函数

package tank_game;
public class main {public static void main(String[] args) {new action();}
}

如需需要图片、音频资源请私聊

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. Linux 后端(node)基本环境安装

    linux作为服务器的优点:1、稳定性2、性能3、易用性4、网络性能、安全性、可管理性5、网络兼容性6、用户和系统管理能力购买阿里云服务器之后,重置实例密码,之后需要重启服务器,用root+密码进程登陆。(远程登陆密码和实例密码不是一个密码,区分清)查看系统cpu信息:cat /…...

    2024/4/28 14:51:04
  2. Python对象自省——运行时判断对象的类型

    简介 自省(introspection)指在运行时判断一个对象的类型 Python中一切都是对象,自省是Python的强项 通过自省可以知道一个对象的能力、状态type() type()返回对象类型 a = list() print(type(a)) # <class list>dir() dir()是自省的一个重要函数,返回列表,列出对象所拥…...

    2024/4/27 22:07:05
  3. 02-完善迭代器

    03-自己实现一个可以迭代的对象demo:from collections import Iterablefrom collections import Iteratorclass Classmate(object):def __init__(self):self.names = []def add(self, name):self.names.append(name)def __iter__(self):“””如果想要一个对象成为一个 可迭代对…...

    2024/4/28 12:42:14
  4. [转载] 解决方案:VS2017 无法打开源文件 stdio.h main.h 等头文件

    亲测得到解决;不过也有其他可能原因造成这个问题, 问题描述: 在VS2017中运行解决方案是有错误:“E1696 无法打开 源 文件 “stdio.h” ”…原因: 这种问题一般发生在该项目代码是在网上下载而来的情况,或者电脑重装新的系统等情况,导致电脑系统与该项目生成时所采用的wi…...

    2024/4/28 5:32:55
  5. 单例模式(Singleton)和 多例模式(Multiton)

    参考:https://www.phpmianshi.com/?id=461、概念简单说来,单例模式的作用就是保证在整个应用程序的生命周期中,任何一个时刻,单例类的实例都只存在一个,同时这个类还必须提供一个访问该类的全局访问点。 常见使用实例:数据库连接器;日志记录器(如果有多种用途使用多例…...

    2024/4/28 2:44:48
  6. 总结:iOS中多线程的经典崩溃

    前言 iOS崩溃是让iOS开发人员比较头痛的事情,app崩溃了,说明代码写的有问题,这时如何快速定位到崩溃的地方很重要。调试阶段是比较容易找到出问题的地方的,但是已经上线的app并分析崩溃报告就比较麻烦了。 本文将给大家总结介绍关于iOS中多线程的一些经典崩溃,下面话不多说…...

    2024/4/28 14:53:28
  7. C++的四种类型转换

    const_cast:去掉(指针或引用 )常量属性的一个类型转换const int a = 10;int *p1 = (int *)&a;int *p2 = const_cast<int*>(&a);char *p3 = (char*)&a;//char *p4 = const_cast<char*>(&a);//double *p4 = const_cast<double*>(&a);在上…...

    2024/4/15 3:07:27
  8. 使用JAXBContext将Xml转换成对象

    做webservice的时候要解析xml,通过查找发先JAXB是可以解析xml并转换成对象的 @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name="标签名称", propOrder={属性名称}) @XmlRootElement public class OrderRequestMsgHeader {/***@XmlElement里面的name跟xml里面的…...

    2024/4/28 18:46:46
  9. 西门子S7-300PLC通过以太网连接组态王KingSCADA软件

    组态王软件作为常用的上位机SCADA软件,常用于系统集成的上位软件应用方案,常与西门子PLC控制系统通过以太网进行通讯和数据记录。组态王内置西门子以太网驱动通道,通过以太网通讯方式连接西门子PLC 的网口、CP343、或者第三方MPI转以太网模块等以太网接口。1、新建工程,填入…...

    2024/4/28 2:37:55
  10. 我丢,创建了接口,没实现就给我报错~~~

    报错信息长这样子,又臭又长,英文一塌糊塌的我只认出了那个自己写的”helloService”和经常见过的“could not be found” Description:A component required a bean of type cn.hello.service.HelloService that could not be found.Action:Consider defining a bean of type…...

    2024/4/24 14:40:48
  11. Python在命令行如何调试?pdb调试解读

    pdb 是 python 自带的一个包,为 python 程序提供了一种交互的源代码调试功能,主要特性包括设置断点、单步调试、进入函数调试、查看当前代码、查看栈片段、动态改变变量的值等。 pdb 常用命令调试方法: 在代码中想要停驻的地方添加: pdb.set_trace() Python -m pdb (py文件…...

    2024/4/24 14:40:47
  12. 创建底三层

    打开vs先创建一个Web程序向里面添加底三层BLL层DAL层Model层且互相添加引用BLL引用DAL和ModelDAL引用ModelModel不需要引用...

    2024/4/24 14:40:46
  13. EBS - 增加并发请求输出类型

    概述主要用于不通过BI Publisher,来生成EXCEL输出文件Excel文件内容,需通过HTML语法画出步骤Step1.创建输出类型应用管理员->应用产品->代码->应用程序对象库->快码值【CP_OUTPUT_FILE_TYPE】因为该快码类型是系统级别,界面无法编辑,故从后台插入注意快码(loo…...

    2024/4/24 14:40:45
  14. 基于OpenCV的车道线检测算法(Traditional Method)

    https://zhuanlan.zhihu.com/p/60891432...

    2024/4/24 14:40:45
  15. 你居然还去服务器上捞日志,搭个日志收集系统难道不香么!

    摘要ELK日志收集系统进阶使用,本文主要讲解如何打造一个线上环境真实可用的日志收集系统。有了它,你就可以和去服务器上捞日志说再见了!ELK环境安装ELK是指Elasticsearch、Kibana、Logstash这三种服务搭建的日志收集系统,具体搭建方式可以参考《SpringBoot应用整合ELK实现日…...

    2024/4/24 14:40:43
  16. 以“智变”应万变,揭秘新华三六大数字化解决方案!

    数字化时代已来临。 在通信网络、社交媒介、基础建设不断演进的进程下,万物互联加速扩展,不仅从基础建设层面改变了人们生活方式,也激发了不少传统的企业开始重新思考原有运作的业务及商业模式,并纷纷投入数字化转型的浪潮中。 不过,虽然「生活就是变革,完美就是不断变化…...

    2024/4/24 14:40:42
  17. Spring 学习,看松哥这一篇万余字干货就够了!

    1. Spring 简介我们常说的 Spring 实际上是指 Spring Framework,而 Spring Framework 只是 Spring 家族中的一个分支而已。那么 Spring 家族都有哪些东西呢?Spring 是为了解决企业级应用开发的复杂性而创建的。在 Spring 之前,有一个重量级的工具叫做 EJB,使用 Spring 可以…...

    2024/4/24 14:40:41
  18. idea远程调试,一个用上就被老大表扬的黑科技

    不知道各位有没有遇见以下情况:​ 【国服第一测试】:我本地环境出了一个bug,那个【稀饭下雪】你过来看看。或者:​ 【国服第一测试】:外网正式服出了一个bug,我导了数据库环境到本地,看了下确实是bug,那个【稀饭下雪】你过来看看。再或者:​ 【国服第一狗策划】:内网…...

    2024/4/24 14:40:40
  19. consul分布式集群搭建

    目录consul特性Consul架构consul概念consul安装及测试安装window下安装开发模式部署集群部署consul服务注册与发现(C#) consul特性 consul是分布式的、高可用、横向扩展的。consul提供的一些关键特性:service discovery:consul通过DNS或者HTTP接口使服务注册和服务发现变的…...

    2024/4/27 22:33:16
  20. 如何给照片换背景?怎么用手机更换证件照背景颜色

    有时候在使用电子版的证件照的时候,由于证件照的背景颜色与要求不符所以无法使用证件照的情况,那么应该如何给照片换背景(https://www.yasuotu.com/coloreplace)?首先我们要知道,不同颜色的证件照是适用于什么情况:一般白底用于身份证、护照、签证、驾驶证、通行证等用于…...

    2024/4/24 14:40:38

最新文章

  1. 【七十一】【算法分析与设计】467. 环绕字符串中唯一的子字符串,940. 不同的子序列 II,子串的划分,子序列的划分,区间划分---递推

    467. 环绕字符串中唯一的子字符串 定义字符串 base 为一个 "abcdefghijklmnopqrstuvwxyz" 无限环绕的字符串&#xff0c;所以 base 看起来是这样的&#xff1a; "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....". 给你一个字符串 s &…...

    2024/4/28 20:06:42
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. CVP(ChatGPT、Vector Database和Prompt)

    CVP实际上指的是ChatGPT、Vector Database和Prompt的结合&#xff0c;这是一种新型的技术栈&#xff0c;用于构建智能应用。 首先&#xff0c;我们来看这三个组成部分&#xff1a; ChatGPT&#xff1a;这是一个强大的语言模型&#xff0c;它能够理解并生成自然语言文本。Chat…...

    2024/4/19 0:05:23
  4. 【Redis】安装Redis后报ERR Client sent AUTH, but no password is set

    一、问题描述 安装Redis后使用auth验证是否安装成功&#xff08;或者其它应用访问redis时报错&#xff09;&#xff0c;报ERR Client sent AUTH, but no password is set 127.0.0.1:6379> auth 123456 (error) ERR Client sent AUTH, but no password is set二、问题解决 …...

    2024/4/25 10:11:11
  5. 基于8086贪吃蛇游戏系统方恨设计

    **单片机设计介绍&#xff0c;基于8086贪吃蛇游戏系统方恨设计 文章目录 一 概要二、功能设计三、 软件设计原理图 五、 程序六、 文章目录 一 概要 基于8086的贪吃蛇游戏系统设计是一个结合了微处理器控制、游戏逻辑以及图形显示技术的综合性项目。该系统旨在通过8086微处理器…...

    2024/4/26 14:37:20
  6. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/4/28 13:52:11
  7. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/4/28 3:28:32
  8. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/4/26 23:05:52
  9. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/4/28 13:51:37
  10. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/4/27 17:58:04
  11. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/4/27 14:22:49
  12. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/4/28 1:28:33
  13. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/4/28 15:57:13
  14. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/4/27 17:59:30
  15. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/4/25 18:39:16
  16. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/4/28 1:34:08
  17. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/4/26 19:03:37
  18. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/4/28 1:22:35
  19. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/4/25 18:39:14
  20. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/4/26 23:04:58
  21. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/4/27 23:24:42
  22. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/4/28 5:48:52
  23. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/4/26 19:46:12
  24. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/4/27 11:43:08
  25. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/4/27 8:32:30
  26. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  27. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  28. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  29. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  30. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  31. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  32. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  33. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  34. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  35. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  36. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  37. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  38. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  39. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  40. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  41. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  42. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  43. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  44. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  45. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57