首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【果壳信奥编程】纯 JAVA 实现植物大战僵尸

【果壳信奥编程】纯 JAVA 实现植物大战僵尸

作者头像
一枚大果壳
发布于 2024-05-18 01:12:02
发布于 2024-05-18 01:12:02
16700
代码可运行
举报
文章被收录于专栏:编程驿站编程驿站
运行总次数:0
代码可运行

没有做太多封装,难免有冗余,有兴趣者取之。

1. pea 类

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.hm;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**

 */
public class Pea {

    BufferedImage image;
    int x;
    int y;
    Rectangle rectangle;
    //宽度
    //高度
    int size;

    public Pea(int x, int y) throws IOException {
        this.image= ImageIO.read(new File("images/background/pea.png"));
        this.x=x;
        this.y=y;
        this.size=25;
        this.rectangle=new Rectangle(this.x,this.y,this.size,this.size);
    }

    public void draw(Graphics g){
        g.drawImage(this.image,this.x,this.y,this.size,this.size,null);
        this.rectangle=new Rectangle(this.x,this.y,this.size,this.size);
        this.x+=50;
    }
}

2. PeaShooter

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.hm;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class PeaShooter {
    BufferedImage image;
    int x;
    int y;
    Rectangle rectangle;
    //预加载所有豌豆射手图片
    BufferedImage[] images=new BufferedImage[13];
    int index=0;
    int live=40;

    public PeaShooter(int x,int y) throws IOException {
        this.x=x;
        this.y=y;
        for (int i = 0; i <13 ; i++) {
            String code=i<9?"0"+(i+1):(i+1)+"";
            images[i]= ImageIO.read(new File("images/peashooter/PeaShooter_"+code+".png"));
        }
        this.image=images[index];
        this.rectangle=new Rectangle(this.x,this.y,this.image.getWidth(),this.image.getHeight());
    }

    public void draw(Graphics graphics){
        index=++index%13;//0 12
        this.image=images[index];
        this.rectangle=new Rectangle(this.x,this.y,this.image.getWidth(),this.image.getHeight());
       // graphics.drawRect(this.x,this.y,this.image.getWidth(),this.image.getHeight());
        graphics.drawImage(this.image,this.x,this.y,this.image.getWidth(),this.image.getHeight(),null);
    }
}

3. Sun

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.hm;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * 自然光(随机)
 * 向日葵生产(与向日葵)
 */
public class Sun {

    BufferedImage image;
    int x;
    int y;
    Rectangle rectangle;
    //宽度
    //高度
    int size;
    //是否被鼠标点击
    int isMeetMouse=0;
    //x长度
    int xlength;
    //y
    int ylength;


    public Sun(int x,int y) throws IOException {
        this.image= ImageIO.read(new File("images/background/Sun.png"));
        this.x=x;
        this.y=y;
        this.size=60;
        this.rectangle=new Rectangle(this.x,this.y,this.size,this.size);
    }

    public void draw(Graphics g){
        this.rectangle=new Rectangle(this.x,this.y,this.size,this.size);
        g.drawImage(this.image,this.x,this.y,this.size,this.size,null);
    }
}

4. SunFlower

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.hm;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class SunFlower {
    BufferedImage image;
    int x;
    int y;
    Rectangle rectangle;
    //预加载所有豌豆射手图片
    BufferedImage[] images=new BufferedImage[18];
    int index=0;
    //生命值
    int live=30;

    public SunFlower(int x, int y) throws IOException {
        this.x=x;
        this.y=y;
        for (int i = 0; i <18 ; i++) {
            String code=i<9?"0"+(i+1):(i+1)+"";
            images[i]= ImageIO.read(new File("images/SunFlower/SunFlower_"+code+".png"));
        }
        this.image=images[index];
        this.rectangle=new Rectangle(this.x,this.y,this.image.getWidth(),this.image.getHeight());
    }

    public void draw(Graphics graphics){
        index=++index%18;//0 12
        this.image=images[index];
        this.rectangle=new Rectangle(this.x,this.y,this.image.getWidth(),this.image.getHeight());
        //graphics.drawRect(this.x,this.y,this.image.getWidth(),this.image.getHeight());
        graphics.drawImage(this.image,this.x,this.y,this.image.getWidth(),this.image.getHeight(),null);
    }
}

5. Zombie

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.hm;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class Zombie {
    BufferedImage image;
    int x;
    int y;
    Rectangle rectangle;
    //预加载所有豌豆射手图片
    BufferedImage[] walkImages = new BufferedImage[31];
    BufferedImage[] dieImages = new BufferedImage[10];
    BufferedImage[] headImages = new BufferedImage[10];
    //吃播图片
    BufferedImage[] eatImages = new BufferedImage[21];
    //索引号
    int index = 0;
    int index_ = 0;
    int indexEat = 0;

    //走 1 正在走,0停
    int run = 1;

    //生命值
    int live = 4;

    public Zombie(int x, int y) throws IOException {
        this.x = x;
        this.y = y;
        for (int i = 0; i < 31; i++) {
            String code = i < 9 ? "0" + (i + 1) : (i + 1) + "";
            walkImages[i] = ImageIO.read(new File("images/Zombie/Walk/Walk_" + code + ".png"));
        }
        for (int i = 0; i < 10; i++) {
            String code = i < 9 ? "0" + (i + 1) : (i + 1) + "";
            dieImages[i] = ImageIO.read(new File("images/Zombie/Die/Die_" + code + ".png"));
        }
        for (int i = 0; i < 10; i++) {
            String code = i < 9 ? "00" + (i + 1) : "0" + (i + 1);
            headImages[i] = ImageIO.read(new File("images/Zombie/Head/Head_" + code + ".png"));
        }
        for (int i = 0; i < 21; i++) {
            String code = i < 9 ? "0" + (i + 1) : (i + 1) + "";
            eatImages[i] = ImageIO.read(new File("images/Zombie/Eat/Eat_" + code + ".png"));
        }
        this.image = walkImages[index];
        this.rectangle = new Rectangle(this.x, this.y, this.image.getWidth(), this.image.getHeight());
    }

    public void draw(Graphics graphics) {
        if (this.live > 0) {
            if (this.run == 1) {
                index = ++index % 31;//0 30
                this.image = walkImages[index];
                this.x -= 5;
            } else {
                indexEat = ++indexEat % 21;//0 30
                this.image = eatImages[indexEat];
            }
        } else {
            index_ = ++index_ % 10;//0 30
            this.image = dieImages[index_];
            graphics.drawImage(this.headImages[index_], this.x, this.y, this.headImages[index_].getWidth() - 20, this.headImages[index_].getHeight() - 20, null);
        }
        this.rectangle = new Rectangle(this.x, this.y, this.image.getWidth() - 20, this.image.getHeight() - 20);
        //graphics.drawRect(this.x, this.y, this.image.getWidth()-20, this.image.getHeight()-20);
        graphics.drawImage(this.image, this.x, this.y, this.image.getWidth() - 20, this.image.getHeight() - 20, null);
    }
}

6. MainFrm

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.hm;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Random;

/**
 * AudionClip sound_choose=Applet.newAdudioClip(sound1.toURL());
 */
public class MainFrm extends JFrame {

    //创建
    BackGround backGround = new BackGround();
    //太阳光数量卡片
    Card sunCountCard;
    //生产向日葵
    Card sunFlowerCard;
    //生产碗豆射手
    Card peaShooterCard;
    //阳光(自然光):定时随时创建
    Sun sun = null;
    //随机
    Random random = new Random();
    //定时器
    Timer timer;
    //阳光从天上移动目标Y
    int sunTargetY;
    //鼠标是否点击到阳光
    int sunMeetMouse = 0;
    //阳光离收集面板x方向长度
    int xlength;
    //阳光离收集面板y方向长度
    int ylength;
    Image offScreenImage = null;
    //阳光数量
    int sunCount = 500;
    //射手是否已经创建
    int isCreatePeaShooter = 0;
    //射手
    PeaShooter peaShooter;
    //是否种下来
    int isPeaFloor = 0;
    //子弹
    Pea pea;
    //容器(子弹)
    LinkedList<Pea> peas = new LinkedList();
    //容器(豌豆射手)
    LinkedList<PeaShooter> peaShooters = new LinkedList();
    //僵尸
    Zombie zombie;
    LinkedList<Zombie> zombies = new LinkedList();
    //一个箱子变量向日葵
    SunFlower sunFlower;
    //保存所有向日葵
    LinkedList<SunFlower> sunFlowers = new LinkedList<>();
    //是否已经存下
    int isSunFlowerDown = 0;

    //向日葵生产阳光
    Sun sun_;
    //容器,保存所有向口葵生产出来的阳光
    LinkedList<Sun> suns = new LinkedList<>();

    //开始
    BufferedImage startImage;

    int total = 50; //总量
    int total_ = total;
    int count = 0;
    //房子
    int isFail=0;
    //成功
    BufferedImage okImage;
    //失败
    BufferedImage noImage;

    public MainFrm() throws IOException {
        startImage = ImageIO.read(new File("images/background/start.jpg"));

        okImage = ImageIO.read(new File("images/background/trophy.png"));
        noImage = ImageIO.read(new File("images/background/ZombiesWon.png"));

        BufferedImage image = ImageIO.read(new File("images/card/plants/SunBank.png"));
        sunCountCard = new Card(image, 200, 40);
        sunCountCard.rectangle.setBounds(200, -10, 100, 100);

        image = ImageIO.read(new File("images/card/plants/SunFlower.png"));
        sunFlowerCard = new Card(image, 265, 40);

        image = ImageIO.read(new File("images/card/plants/Peashooter.png"));
        peaShooterCard = new Card(image, 325, 40);

        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        //大小
        this.setSize(1400, 600);
        //位置
        this.setLocation(200, 100);
        //标题
        this.setTitle("植物大战僵尸");
        //
        this.setResizable(false);

        //使用定时器
        timer = new Timer(100, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                if (sun == null) {
                    try {
                        //创建阳光(自然光)
                        createSun();
                        //定制一个目标点
                        sunTargetY = random.nextInt(300) + 100;

                    } catch (IOException ioException) {
                        ioException.printStackTrace();
                    }
                } else {
                    //阳光存在让其移动
                    sunMove();
                }
                //创建子弹
                if (pea == null && peaShooters.size() != 0) {
                    try {
                        //根据武器数量调整生产子弹的频率
                        int wuCount = peaShooters.size();
                        int num_ = 5;
                        if (wuCount > 5) {
                            num_ = 1;
                        }
                        int randNum = random.nextInt(num_);//0~9
                        if (randNum == 0) { //1/5
                            int num = random.nextInt(peaShooters.size());//
                            //从武器库中根据随机数字得到武器
                            PeaShooter ps = peaShooters.get(num);
                            if (ps != peaShooter) {
                                //随机出来的武器不是正在移动的武器
                                pea = new Pea(ps.x + 80, ps.y);
                                //添加容器中
                                peas.addLast(pea);
                                pea = null;
                            }
                        }

                    } catch (Exception ioException) {
                        ioException.printStackTrace();
                    }
                }

                //向日葵生产阳光
                if (sun_ == null && sunFlowers.size() != 0) {
                    try {
                        //频率
                        int wuCount = sunFlowers.size();
                        int num_ = 20;
                        if (wuCount > 10) {
                            num_ = 10;
                        }
                        int randNum = random.nextInt(num_);//0~9
                        if (randNum == 0) { //1/5
                            int num = random.nextInt(sunFlowers.size());//
                            //根据随机数字得到太阳花
                            SunFlower ps = sunFlowers.get(num);
                            if (ps != sunFlower) {
                                sun_ = new Sun(ps.x, ps.y);
                                //添加容器中
                                suns.addLast(sun_);
                                sun_ = null;
                            }
                        }
                    } catch (Exception ioException) {
                        ioException.printStackTrace();
                    }
                }
                if (suns.size() != 0) {
                    sunMove_();
                }

                //生产僵尸
                if (zombie == null && count != total_) {
                    int jsNum = random.nextInt(30);
                    if (jsNum == 10) {
                        int y = random.nextInt(350) + 50;//0~9
                        try {
                            zombie = new Zombie(1300, y);
                            count++;
                            zombies.addLast(zombie);
                            zombie = null;

                        } catch (IOException ioException) {
                            ioException.printStackTrace();
                        }
                    }
                }
                peaIsMeetZombie();
                isZombieMeetSunFlowerOrPeaShooter();
                repaint();
            }
        });

        timer.start();
        //窗体接收鼠标点击
        this.addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                if (peaShooter != null) {
                    if (isPeaFloor == 0) {
                        //没有种下时与鼠标一起移动
                        peaShooter.x = e.getX();
                        peaShooter.y = e.getY();
                    } else {
                        //种下之后恢复变量到初始状态
                        peaShooter = null;
                        isPeaFloor = 0;
                    }
                }
                if (sunFlower != null) {
                    if (isSunFlowerDown == 0) {
                        //没有种下时与鼠标一起移动
                        sunFlower.x = e.getX();
                        sunFlower.y = e.getY();
                    } else {
                        //种下之后恢复变量到初始状态
                        sunFlower = null;
                        isSunFlowerDown = 0;
                    }
                }
            }
        });
        this.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                //鼠标坐标是否和阳光的坐标叠
                if (sunMeetMouse == 0 && sun != null) {
                    if (sun.rectangle.contains(e.getX(), e.getY())) {
                        sunMeetMouse = 1;
                        xlength = Math.abs(sun.x - 200);
                        ylength = Math.abs(sun.y - 40);
                    }
                }
                //检查鼠标是不是点击到了向日葵所生产的阳光
                if (suns.size() != 0) {
                    for (Sun s : suns) {
                        if (s.rectangle.contains(e.getX(), e.getY())) {
                            //有阳光碰到鼠标
                            s.isMeetMouse = 1;
                            s.xlength = Math.abs(s.x - 200);
                            s.ylength = Math.abs(s.y - 40);
                            break;
                        }
                    }
                }

                //种植武器
                if (peaShooter == null) {
                    if (peaShooterCard.rectangle.contains(e.getX(), e.getY())) {
                        if (sunCount >= 100) {
                            try {
                                //创建一个 武器
                                peaShooter = new PeaShooter(e.getX(), e.getY());
                                //放置武器容器
                                peaShooters.addLast(peaShooter);
                                sunCount -= 100;
                            } catch (IOException ioException) {
                                ioException.printStackTrace();
                            }
                        }
                    }
                } else {
                    isPeaFloor = 1;
                }
                //种植太阳花
                if (sunFlower == null) {
                    if (sunFlowerCard.rectangle.contains(e.getX(), e.getY())) {
                        if (sunCount >= 50) {
                            try {
                                //创建一个 武器
                                sunFlower = new SunFlower(e.getX(), e.getY());
                                //放置武器容器
                                sunFlowers.addLast(sunFlower);
                                sunCount -= 50;
                            } catch (IOException ioException) {
                                ioException.printStackTrace();
                            }
                        }
                    }
                } else {
                    isSunFlowerDown = 1;
                }
            }
        });
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        if (offScreenImage == null) {
            offScreenImage = this.createImage(1400, 600);
        }
        g.drawImage(offScreenImage, 0, 0, null);

        Graphics gOffScreen = offScreenImage.getGraphics();
        //2D
        Graphics2D graphics2D = (Graphics2D) gOffScreen;

        gOffScreen.fillRect(0, 0, 1400, 600);
        gOffScreen.setColor(Color.white);

        this.backGround.draw(gOffScreen);
        this.sunCountCard.draw(gOffScreen);
        this.sunFlowerCard.draw(gOffScreen);
        this.peaShooterCard.draw(gOffScreen);

        //绘制分值
        gOffScreen.setFont(new Font("黑体", Font.BOLD, 20));
        gOffScreen.setColor(Color.red);
        gOffScreen.drawString(this.sunCount + "", 215, 110);

        //绘制所有武器
        if (this.peaShooters != null) {
            for (int i = 0; i < peaShooters.size(); i++) {
                peaShooters.get(i).draw(gOffScreen);
            }
        }

        //绘制所有太阳花
        if (this.sunFlowers != null) {
            for (int i = 0; i < sunFlowers.size(); i++) {
                sunFlowers.get(i).draw(gOffScreen);
            }
        }

        //绘制阳光
        if (this.sun != null)
            this.sun.draw(gOffScreen);

        //绘制所有僵尸
        if (zombies.size() != 0) {
            for (int i = 0; i < zombies.size(); i++) {
                zombies.get(i).draw(gOffScreen);
            }
        }
        //绘制豌豆子弹
        if (peas != null) {
            for (int i = 0; i < peas.size(); i++) {
                if (peas.get(i).x > 1400) {
                    peas.remove(peas.get(i));
                    continue;
                }
                peas.get(i).draw(gOffScreen);
            }
        }

        //绘制豌豆子弹
        if (suns != null) {
            for (int i = 0; i < suns.size(); i++) {
                if (suns.get(i).x > 1400) {
                    suns.remove(suns.get(i));
                    continue;
                }
                suns.get(i).draw(gOffScreen);
            }
        }

        gOffScreen.setFont(new Font("黑体", Font.BOLD, 30));
        //绘制数量
        gOffScreen.drawString("当前的僵尸数量:" + this.total, 400, 100);
        //全部消灭之后
        if (this.total == 0) {
            gOffScreen.drawImage(this.okImage, 600, 200, this.okImage.getWidth(), this.okImage.getHeight(), null);


        }
        if (this.isFail==1){
            gOffScreen.drawImage(this.noImage, 400, 100, this.noImage.getWidth(), this.noImage.getHeight(), null);
        }
    }

    /**
     * 生产自然光
     */
    public void createSun() throws IOException {
        //指定位置
        int y = -100;
        int x = this.random.nextInt(500) + 260;//260 760
        sun = new Sun(x, y);
    }

    /**
     * 移动阳光
     */
    public void sunMove() {
        //确定目标坐标
        if (sunMeetMouse == 0) {
            if (this.sun.y < this.sunTargetY)
                this.sun.y += 25;
        } else if (sunMeetMouse == 1) {
            if (this.sunCountCard.rectangle.contains(this.sun.x + 50, this.sun.y + 50)) {
                this.sunCount += 25;
                //重置阳光数据
                this.sun = null;
                this.sunMeetMouse = 0;
            } else {
                //设定y速度
                int yspeed = 15;
                //求解X轴
                int xspeed = (yspeed * xlength) / ylength;
                this.sun.x -= xspeed;
                this.sun.y -= yspeed;
            }
        }
        if (this.sun != null)
            this.sun.rectangle.setBounds(this.sun.x, this.sun.y, this.sun.size, this.sun.size);
    }

    public void sunMove_() {
        //确定目标坐标
        for (int i = 0; i < suns.size(); i++) {
            Sun s = suns.get(i);
            if (s == null)
                continue;
            if (s.isMeetMouse == 1) {
                if (this.sunCountCard.rectangle.intersects(s.rectangle)) {
                    this.sunCount += 25;
                    //重置阳光数据
                    s.isMeetMouse = 0;
                    suns.remove(s);
                } else {
                    //设定y速度
                    int yspeed = 15;
                    //求解X轴
                    int xspeed = (yspeed * s.xlength) / s.ylength;
                    s.x -= xspeed;
                    s.y -= yspeed;
                }
            }
        }
    }

    //添加方法:检查子弹是不是碰到了僵尸
    public void peaIsMeetZombie() {
        //
        for (int i = 0; i < zombies.size(); i++) {
            //僵尸
            Zombie zb = zombies.get(i);
            if (zb == null)
                continue;
            //回收
            if (zb.index_ >= 9) {
                zombies.remove(zb);
                this.total--;
                if (this.total == 0) {
                    //timer.stop();
                    //repaint();
                   // return;
                }
                break;
            }
            //检查是否已经全部死亡

            for (int j = 0; j < peas.size(); j++) {
                Pea p = peas.get(j);
                if (p == null)
                    continue;
                if (zb.rectangle.intersects(p.rectangle)) {
                    if (zb.live > 0)
                        zb.live -= 1;
                    peas.remove(p);
                }
            }
        }
    }

    /**
     * 僵尸碰到植物
     */
    public void isZombieMeetSunFlowerOrPeaShooter() {
        for (int i = 0; i < zombies.size(); i++) {
            Zombie zb = zombies.get(i);
            if (zb == null) continue;
            if (zb.x<150){
                this.isFail=1;
            }
            if (zb.x<130){
                timer.stop();
                return;
            }
            //太阳花
            for (int j = 0; j < sunFlowers.size(); j++) {
                SunFlower sf = sunFlowers.get(j);
                if (sf == null) continue;
                if (zb.rectangle.contains(sf.rectangle) && sunFlower == null) {
                    if (sf.live > 0) {
                        zb.run = 0;
                        sf.live--;
                    } else {
                        zb.run = 1;
                        sunFlowers.remove(sf);
                    }
                    break;
                }
            }
            for (int j = 0; j < peaShooters.size(); j++) {
                PeaShooter ps = peaShooters.get(j);
                if (ps == null) continue;
                if (zb.rectangle.contains(ps.rectangle) && peaShooter == null) {
                    if (ps.live > 0) {
                        zb.run = 0;
                        ps.live--;
                    } else {
                        zb.run = 1;
                        peaShooters.remove(ps);
                    }
                    break;
                }
            }
        }

    }
}

7. Card

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.hm;

import java.awt.*;
import java.awt.image.BufferedImage;

public class Card {
    //图片
    BufferedImage image;
    int x;
    int y;
    //范围
    Rectangle rectangle;

    public Card(BufferedImage image,int x,int y){
        this.image=image;
        this.x=x;
        this.y=y;
        this.rectangle=new Rectangle(this.x,this.y,60,75);
    }

    /**
     * 绘制
     */
    public void draw(Graphics graphics){
        graphics.drawImage(this.image,this.x,this.y,60,75,null);
    }
}

8.BackGround

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
package com.hm;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * 背景有关代码
 */
public class BackGround {
    //图片
    BufferedImage image;
    //位置 x
    int x;
    //y
    int y;

    public BackGround() throws IOException {
        //加载图片
        this.image= ImageIO.read(new File("images/background/background1.jpg"));
        this.x=0;
        this.y=0;
    }

    /**
     * 绘制
     */
    public  void draw(Graphics graphics){
        graphics.drawImage(this.image,this.x,this.y,1400,600,null);
    }
}
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-05-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 编程驿站 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
6 条评论
热度
最新
111举报
回复回复点赞举报
11点赞举报
回复回复点赞举报
太厉害啦!
太厉害啦!
11点赞举报
回复回复点赞举报
推荐阅读
盘点 9 个 数据库MCP:Supabase、Neon、PostgreSQL、SQLite、MongoDB、MindsDB。
最新MCP托管平台:让Cursor秒变数据库专家,一键对接Github,开发效率暴增!
AI进修生
2025/07/02
3240
盘点 9 个 数据库MCP:Supabase、Neon、PostgreSQL、SQLite、MongoDB、MindsDB。
Dify + OceanBase + MCP:三剑合璧,轻松构建 RAG 应用
在 AI 应用开发领域,检索增强生成(Retrieval Augmented Generation,RAG)已成为构建智能问答、文档分析等场景的核心技术。通过 RAG,AI 应用能够结合现有知识库,在生成回答时引入外部信息,从而为用户提供更准确、更智能的响应。本文将通过一个实践案例,展示如何使用 Dify、OceanBase 和 MCP,从零开始构建一个功能完备的 RAG 应用。
Se7en258
2025/06/28
2290
Dify + OceanBase + MCP:三剑合璧,轻松构建 RAG 应用
用 Gradio, 几行 Python 代码构建 MCP 服务器!
长期跟踪关注统计学、机器学习算法、深度学习、人工智能、大模型技术与行业发展动态,日更精选技术文章。回复机器学习有惊喜资料。
Ai学习的老章
2025/06/08
1940
用 Gradio, 几行 Python 代码构建 MCP 服务器!
一个让DevOps癫狂的项目一键部署数百个MCP服务器
MCP(Model Context Protocol)是一种新兴的标准化协议,用于管理大型语言模型(LLM)与外部系统之间的上下文交互。随着 AI 技术的快速发展,越来越多的开发者需要将 LLMs 与各种外部工具、API 和数据源集成。然而,MCP 服务器的设置和维护通常较为繁琐,涉及复杂的依赖管理和配置过程,这对开发效率构成了挑战。
IT运维技术圈
2025/04/24
3550
一个让DevOps癫狂的项目一键部署数百个MCP服务器
yapi简介,安装及使用
​ YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 API,YApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。
iginkgo18
2022/05/09
1.6K0
yapi简介,安装及使用
大语言模型交互协议 MCP SDK Go-MCP 正式开源!
今天,ThinkInAI 团队(前身为 GoCN 团队)自豪地宣布,基于 Go 语言的大模型交互协议(Model Context Protocol)SDK —— Go-MCP 正式开源!
深度学习与Python
2025/04/10
2K0
大语言模型交互协议 MCP SDK Go-MCP 正式开源!
开源Registry项目Harbor源代码结构解析
容器应用的开发和运行离不开可靠的镜像管理。从安全和效率等方面考虑,在企业私有环境内部署的Registry服务是非常必要的。Harbor(https://github.com/vmware/harbor)是由VMware中国研发团队为企业用户设计的Registry Server开源项目,包括了权限管理(RBAC)、图形管理界面、LDAP/AD集成、审计、自我注册、HA等企业必需的功能,同时针对中国用户的特点,原生支持中文,并计划实现镜像复制(roadmap)等功能。
Henry Zhang
2019/04/12
1.4K0
开源Registry项目Harbor源代码结构解析
Nacos 发布 MCP Registry,实现存量应用接口“0改动”升级到 MCP 协议
MCP 的发展速度之快,似乎超出了大部分人的想象。今年 2 月,Cursur、Winsurf、Cline 均开始引入 MCP,近日 OpenAI 宣布支持 MCP,国内百度地图、高德地图陆续发布 MCP Server,还有一众非常活跃的提供 MCP 托管和中间件服务的供应商,MCP 生态正呈现越加丰富和成熟的发展态势。虽然 AI 在短期内依旧面临 ROI 的考验,但几乎所有人都不会怀疑他的未来,都不希望错过这一场“军备竞赛”。问题随之而来,存量业务架构中的 API 改造成 MCP Server,既面临时间成本,还有人力上的挑战。企业对能提升 MCP 构建效率的开源和商业方案愈加渴望。
深度学习与Python
2025/04/04
8420
Nacos 发布 MCP Registry,实现存量应用接口“0改动”升级到 MCP 协议
FastAPI-MCP开源:简化FastAPI与AI智能体的集成
最近,一个叫作 FastAPI-MCP 的开源库问世,旨在帮助开发者更轻松地将传统 FastAPI 应用程序与现代 AI 智能体通过模型上下文协议 (MCP) 连接起来。FastAPI-MCP 旨在实现零配置,使得开发者能够自动将 API 端点暴露为与 MCP 兼容的服务,从而以最小的改动让 Web 服务对 AI 系统可用。
深度学习与Python
2025/04/26
5980
FastAPI-MCP开源:简化FastAPI与AI智能体的集成
微服务 2.0 技术栈选型手册
2014年可以认为是微服务1.0的元年,当年有几个标志性事件,一是Martin Fowler在其博客上发表了“Microservices”一文,正式提出微服务架构风格;二是Netflix微服务架构经过多年大规模生产验证,最终抽象落地形成一整套开源的微服务基础组件,统称NetflixOSS,Netflix的成功经验开始被业界认可并推崇;三是Pivotal将NetflixOSS开源微服务组件集成到其Spring体系,推出Spring Cloud微服务开发技术栈。
芋道源码
2019/05/09
2K1
微服务 2.0 技术栈选型手册
Manus 是大模型 AI Agent + MCP, 那什么是模型上下文协议 (MCP)?
如何让自己使用的大模型能够像 Manus 一样,胜任各种复杂任务,应该采取哪些措施?
技术人生黄勇
2025/03/18
1.3K0
Manus 是大模型 AI Agent + MCP, 那什么是模型上下文协议 (MCP)?
微服务2.0技术栈选型手册
一晃三年过去,微服务技术生态又发生了巨大变化,容器,PaaS,Cloud Native,gRPC,ServiceMesh,Serverless等新技术新理念你方唱罢我登场,不知不觉我们又来到了微服务2.0时代。基于近年在微服务基础架构方面的实战经验和平时的学习积累,我想总结并提出一些构建微服务2.0技术栈的选型思路,供各位在一线实战的架构师、工程师参考借鉴。对于一些暂时还没有成熟开源产品的微服务支撑模块,我也会给出一些定制自研的设计思路。
纯洁的微笑
2018/12/07
2K0
微服务2.0技术栈选型手册
构建自己的简单微服务架构(开源)
本篇仅作引导,内容较多,如果阅读不方便,可以使用电脑打开我们的文档官网进行阅读。如下图所示:
雪雁-心莱科技
2019/05/23
2.8K0
构建自己的简单微服务架构(开源)
全面解析 Model Context Protocol(MCP)及其在 LangChain 中的实践:打造真正可用的本地AI助手
随着大语言模型(LLM)的广泛应用,AI 系统在处理复杂任务时,常常需要与外部数据源和工具进行交互。然而,传统的集成方式存在接口碎片化、上下文封闭、安全隐患和复用性差等问题。​
Lethehong
2025/05/07
1.8K0
全面解析 Model Context Protocol(MCP)及其在 LangChain 中的实践:打造真正可用的本地AI助手
20000颗星!100+Agent工具开源引爆GitHub,程序员集体沸腾!
上周四,OpenAI宣布其Agent SDK已支持MCP,这一消息在智能体领域引起了广泛关注,带来了功能和开发流程的重大变化。此外,OpenAI的桌面版ChatGPT和API也迅速整合了MCP的支持。
福大大架构师每日一题
2025/04/01
4130
20000颗星!100+Agent工具开源引爆GitHub,程序员集体沸腾!
大模型应用系列:两万字解读MCP
【引】AI Agent的实际效能高度依赖于其可集成的工具生态。当Agent无法接入关键数据源或功能接口时,其应用价值将大幅受限。这一核心挑战直接决定了Agent能否在真实场景中发挥作用。
半吊子全栈工匠
2025/04/26
91.8K59
大模型应用系列:两万字解读MCP
什么是MCP?技术原理是什么?教你15分钟配置本地MCP服务
在人工智能(AI)快速发展的今天,AI模型与外部工具的集成成为提升工作效率的关键。然而,传统集成方式存在接口碎片化、开发成本高、安全风险大等问题。为解决这些痛点,MCP(Model Context Protocol,模型上下文协议)应运而生。作为一种开放标准协议,MCP为AI模型与外部工具之间建立了标准化连接通道,推动了AI从“孤立文本生成”向“行动代理”的进化。
星哥玩云
2025/05/15
4.9K0
什么是MCP?技术原理是什么?教你15分钟配置本地MCP服务
深入解析Model Context Protocol:微软开源MCP初学者指南项目
在人工智能快速发展的今天,如何让 AI 模型与客户端应用程序之间建立标准化的交互机制,已成为开发者们亟待解决的关键问题。微软近期开源的 mcp-for-beginners 项目,为我们提供了一个系统性学习 Model Context Protocol (MCP) 的绝佳机会。这个项目不仅涵盖了 MCP 的核心概念,更重要的是提供了 C#、Java、JavaScript、TypeScript 和 Python 五种主流编程语言的实践示例,为不同技术背景的开发者打开了通往 AI 标准化协议的大门。
CoderJia
2025/06/08
4770
快速上手JHipster (Java Hipster)创建应用
JHipster简单来看是一个代码生成器,能够快速创建基于Spring Boot + AngularJS的应用程序。所以这就要求对Spring、Spring Boot要有所了解。 JHipster使用Node.js和Yeoman产生Java应用代码,使用Maven或者Gradle运行产生的代码
Bobby
2018/04/13
7.8K2
快速上手JHipster (Java Hipster)创建应用
自动化文档系统:微服务下的 API 管理利器
随着微服务的盛行和服务粒度的细化,对我服务的 API 接口也越来越多。如果技术管理不到位,技术债的累积会导致服务接口数量爆炸,最后变成业务开发的沉重包袱。据说有的公司,微服务个数不超 300 但 API 接口成功超越5万,这数字估计任何人听到都会头大。
鲍远林
2020/06/12
2K0
自动化文档系统:微服务下的 API 管理利器
推荐阅读
相关推荐
盘点 9 个 数据库MCP:Supabase、Neon、PostgreSQL、SQLite、MongoDB、MindsDB。
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档