?? class_bullet.java
字號:
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.LayerManager;
// Download by http://www.codefans.net
public class Class_Bullet extends Class_GameObject
{
MIDlet_Main mainMIDlet;
//初始坐標
short createX,createY;
//初始角度
short createAngle;
//初始速度
short createV;
//飛行時間
short flyTime;
short damage;
public Class_Bullet(Image img,byte width, byte height)
{
super(img, width, height);
}
public void setMove(Class_Tank ct,LayerManager lm)
{
if(isVisible())
{
//飛行時間開始記數
flyTime++;
short refPixelX,refPixelY;
//根據坦克朝向、初始坐標、初始速度、初始角度、飛行時間來計算子彈坐標
if(!ct.isTowardsRight)
{
refPixelX=(short) (createX+((-1)*createV*flyTime*cos[createAngle/3]/100000));
refPixelY=(short) (createY+((-1)*createV*flyTime*sin[createAngle/3]/100000+35*flyTime*flyTime/100));
}else
{
refPixelX=(short) (createX+(createV*flyTime*cos[createAngle/3]/100000));
refPixelY=(short) (createY+((-1)*createV*flyTime*sin[createAngle/3]/100000+35*flyTime*flyTime/100));
}
setRefPixelPosition(refPixelX,refPixelY);
//如果子彈超出地圖范圍(上界除外),則刪除子彈,并結束該回合
if(getX()<-getWidth()||getX()>Class_Map.width||getY()>Class_Map.height)
{
delete(lm);
Canvas_Main.isTurnChange=true;
}
System.gc();
}
}
//回合初始化,用于保證下列參數每次進入回合后不受上一回合的影響
public void turnInit(Class_Tank ct)
{
flyTime=0;
createAngle=(short) ct.aimAngle;
createV=(short) ct.chargeV;
if(!ct.isTowardsRight)
{
createX=(short) ct.getX();
createY=(short) ct.getY();
}else
{
createX=(short) (ct.getX()+ct.getWidth());
createY=(short) ct.getY();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -