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

📄 herobullet.java~11~

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

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

public class HeroBullet extends Base {


    int speedx, speedy; //速度
    Image img;
    Image shadow;
    int frameWidth, frameHeight;
    Tools tool;
    boolean visble; //可见不可见
    int x, y; //坐标
   static int type; //类型
    Canvas1 mc;
    final int hero1_1 = 1;
  final int hero1_2 = 4;//3發子彈兩顆傾斜
    final int hero2_1= 2;
    final int hero3_1= 3;
    int frameCntX; //子弹图片X指针
    int frameCntY; //子弹图片Y指针

    public HeroBullet(Canvas1 mc, int type) {

        this.mc = mc;
         tool = new Tools(this.mc);
        this.type = type;
        switch (type) {
        case hero1_1:
            img = tool.getImage("/H1_bullet.png");
            break;
        case hero2_1:
               img = tool.getImage("/H2_bullet.png");
            break;
        case hero3_1:
               img = tool.getImage("/H3_bullet.png");
            break;
        }

    }


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

            speedy = -7;
            break;
            case hero1_2:



                break;
        case hero2_1:
            break;
        case hero3_1:
            break;
        }
        this.setVisble(true);

    }

    public void move() {
        switch (type) {
        case hero1_1:
            this.x+= speedx;
            this.y += speedy;
            break;
        case hero2_1:
            break;
        case hero3_1:
            break;
        }

    }

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

          tool.drawPartImage(g,img,x,y,frameCntX*15,frameCntY*24,15,24);//中间子弹
          switch (type) {
          case hero1_1:
              tool.drawPartImage(g,img,x,y,frameCntX*15,frameCntY*24,15,24);//中间子弹
              break;
              case hero1_2:
  tool.drawPartImage(g,img,x,y,frameCntX*15,frameCntY*24,15,24);//中间子弹
  tool.drawPartImage(g,img,x,y,frameCntX*15,frameCntY*24,15,24);//左子弹
  tool.drawPartImage(g,img,x,y,frameCntX*15,frameCntY*24,15,24);//右间子弹
                  break;
          case hero2_1:
              break;
          case hero3_1:
              break;
        }


        }

    }

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

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

}

⌨️ 快捷键说明

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