⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bullet.java~9~

📁 这个是最早期的一个飞行射击游戏 简单实现了地图滚动 子弹碰撞 与 UI等
💻 JAVA~9~
字号:
package newgame;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class Bullet extends Base {


    int speedx, speedy; //速度
    Image img;
    Image shadow;
    int frameWidth, frameHeight;
Tools tool;
    boolean visble; //可见不可见
    int x, y; //坐标
    int type; //类型
    Canvas1 mc;
   final int hero = 1;
   final int enemy = 2;
    final int boss = 3;

    /**
switch (type) {
       case hero:
           break;
       case enemy:
           break;
       case boss:
           break;
        }*/

    public Bullet(Canvas1 mc, int type) {
          tool=new Tools(this.mc);
        this.mc = mc;
  this.type = type;
  switch (type) {
       case hero:img=tool.getImage("/ammo.png");

           break;
       case enemy:
           break;
       case boss:
           break;
        }


    }


    public void setPosition(int x, int y) {
        this.x = x;
        this.y =y;
        switch (type) {
        case hero:

            speedy = -7;
            break;
        case enemy:
            break;
        case boss:
            break;
        }

    }

    public void move() {
        switch (type) {
        case hero:
            if (this.y < 0) {
                this.setVisble(false);
                if (this.isVisble()) {
                    this.x += speedx;
                    this.y += speedy;

                }
            }

            break;
        case enemy:
            break;
        case boss:
            break;
        }

    }

    public void paint(Graphics g) {
        if (this.isVisble()) {

            g.drawImage(img, x, y, g.LEFT | g.TOP);
        }

    }

    public void setVisble(boolean flag) {
        this.visble = flag;
    }

    public boolean isVisble() {
        return this.visble;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -