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

📄 helicopter.java

📁 Source-DeathFlight手机游戏,死亡飞行,适合初学者学习.
💻 JAVA
字号:
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
import java.io.*;

public class Helicopter {
	
	public boolean alive;
	
	private GameObject heliBody = null;
	
	private GameObject heliScrew = null;
	
	private GameObject exploit = null;
	
	private Image img;
	
	private Rect playerRect = null;
	
	public boolean dying = false;
	
	public Helicopter() {
		
		alive = true;
		
		try {
			img = Image.createImage("/res/helicopter.png");
		}
		catch (IOException ioe){
			ioe.printStackTrace();
		}
		heliBody = new GameObject(img,12,28);
		heliBody.lifetime = 1;
		
		try{
			img = Image.createImage("/res/screws.png");
		}catch (IOException ioe){
			ioe.printStackTrace();
		}
		heliScrew = new GameObject(img,8,24);
		heliScrew.lifetime = 7;
		
		img = null;
		
		try {
			img = Image.createImage("/res/exploit.png");
		}catch(IOException ioe){
			ioe.printStackTrace();
		}
		exploit = new GameObject(img,30,30);
		exploit.lifetime = 4;
		exploit.speed = 1;
		
		playerRect = new Rect(0,0,0,0);
	}
	
	public void update(){
		if(dying == true){
			if(exploit.alive == true)exploit.update();
			else alive = false;
			return;
		}
		if(heliScrew.alive == true)heliScrew.update();
		else heliScrew.reset();
	}
	
	public void move(int x,int y){
		
	}
	
	public void moveto(int x,int y){
		playerRect.top = y;
		playerRect.left = x;
		playerRect.right = x + 16;
		playerRect.bottom = y + 34;
		exploit.moveto(x,y);
		heliScrew.moveto(x,y);
		heliBody.moveto(x+4,y+6);
	}
	
	public void paint(Graphics g){
		if(dying == true && alive == true){
			exploit.paint(g);
			return;
		}
		if (!alive)
			return;
		heliBody.paint(g);
		heliScrew.paint(g);
	}
	
	public Rect getPlayerRect(){
		return playerRect;
	}
	
}

⌨️ 快捷键说明

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