You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java Swing实现Flappy Bird时下管道图形异常问题求助

Flappy Bird下管道显示异常问题求助

Flappy Bird运行画面

以下是使用Java Swing JPanel实现的图形显示部分代码:

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    // Draw background image
    backgroundImage.paintIcon(this, g, 0, 0);

    // Draw obstacles
    for (Rectangle obstacle : obstacles) {
        int pipeSpace = space; // space between upper and lower pipes
        int lowerPipeHeight = 600 - obstacle.height - pipeSpace;

        // Draw lower pipe
        g.drawImage(lowerPipeIcon.getImage(), obstacle.x, obstacle.y
                + obstacle.height + pipeSpace, obstacle.width,
                lowerPipeHeight, this);

        // Draw upper pipe
        g.drawImage(upperPipeIcon.getImage(), obstacle.x, obstacle.y,
                obstacle.width, obstacle.height, this);
    }
}

下管道始终显示异常,我尝试过多种修改代码的方法,但问题反而变得更糟。游戏核心代码大多在Launcher和FlappyBird文件中,恳请技术大佬帮忙解决这一棘手问题。

内容的提问来源于stack exchange,提问作者Joshi Minh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 15:32:10