Java JUI打字小游戏项目

这是一个基于Java JUI的打字游戏项目,包括游戏页面、暂停和结束页面的展示。游戏素材包括单词列表和相关图片,可以从提供的链接进行下载。代码实现了单词类和功能类,用于游戏的核心逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

JUI打字游戏

效果展示

游戏页面
在这里插入图片描述
在这里插入图片描述

暂停图
在这里插入图片描述

游戏结束页面
在这里插入图片描述

素材

链接: 单词素材
提取码: 95a8
链接:图片素材
提取码: 7s1u

代码实现

子弹类:
package www.git;

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

/*
 *@author Liu
 *@Description 创建子弹类
 *@data 2021/12/8
 */
public class Bullet {
   
    private int x;
    private int y;
    private int speed;
    public static BufferedImage image;

    static {
   
        try {
   
            image = ImageIO.read(Bullet.class.getResourceAsStream("1bullet.png"));
        } catch (IOException e) {
   
            e.printStackTrace();
        }
    }

    public void step() {
   
        this.y -= this.speed;
    }


    public Bullet(int x) {
   
        this.x = x;
        this.y = Typer.HEIGHT;
        this.speed = 12;
    }

    public int getX() {
   
        return x;
    }

    public void setX(int x) {
   
        this.x = x;
    }

    public int getY() {
   
        return y;
    }

    public void setY(int y) {
   
        this.y = y;
    }

    public int getSpeed() {
   
        return speed;
    }

    public void setSpeed(int speed) {
   
        this.speed = speed;
    }

    public BufferedImage getImage() {
   
        return image;
    }

    public void setImage(BufferedImage image) {
   
        this.image = image;
    }

}
单词课程类
```java
package www.git;

import java.io.*;
import java.util.LinkedList;
import java.util.List;

/*
 *@author Liu
 *@Description
 *@data 2021/12/7
 */
public class Course {
   
    private String name;//第一行的内容
    private String content;//第二行的内容
    private List<Word> list;
    private int index;
    public Course(File file, int index) throws IOException {
   
        if (!file.exists()) {
   
            System.out.println("文件不存在!");
            return;
        }
        InputStreamReader isr = new InputStreamReader(new FileInputStream(file));
        BufferedReader br = new BufferedReader(isr);
       this.name=br.readLine().trim();
       this.content=br.readLine().trim();
       this.list=new LinkedList<>();
        String line=null;
        while ((line=br.readLine()) != null) {
   
            line=line.trim();
            if (line.length()!=0) {
   
                String[] s = line.trim().split("\\s+");
                Word word = new Word(s[1], s[0]);
                this.list.add(word);
            }
        }
        this.index=index;
    }

    public String getName() {
   
        return name;
    }

    public void setName(String name) {
   
        this.name = name;
    }

    public String getContent() {
   
        return content;
    }

    public void setContent(String content) {
   
        this.content = content;
    }

    public List<Word> getList() {
   
        return list;
    }

    public void setList(List<Word> list) {
   
        this.list = list
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

抹泪的知更鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值