📄 ball.java
字号:
/*
* Ball.java
*
* Created on 2006年3月13日, 下午2:21
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
package Creature;
import Snowball.*;
import java.lang.Math;
import java.util.Random;
import javax.microedition.lcdui.game.Sprite;
/**
*
* @author Administrator
*
*/
public class Ball extends Creature{
/*
* 参数
*/
private int Vx;//水平速度
private int Vy;//垂直速度
public int BallPower; //子弹能量 初始能量
public int BallDistance;//子弹距离 初始射程 10 加长后 15
//临时坐标记录
public int TempX ;
public int TempY ;
/** Creates a new instance of Ball */
public Ball(int x, int y, int WalkDir, Sprite ImageL, Sprite ImageR)
{
super(x, y, WalkDir, ImageL, ImageR);
//设置子弹参数
//速度
Vx = 8;
Vy = 1;
//帧的宽,高
frameWidth = 25;
frameHeight = 5;
//状态
State = false; //逻辑状态
DrawState = false;//绘画状态
//射程
BallDistance = 50;
//子弹能量
BallPower = 10;
}
public void Process(int TickCount){
Move(WalkDir);
CheckBallDistance();
}
//移动
private void Move(int WalkDir){
switch(WalkDir){
case 0:
//水平
x = x - Vx;
//垂直
y = y + Vy;
break;
case 1:
//水平
x = x + Vx;
//垂直
y = y + Vy;
break;
}
}
//判断子弹射程
private void CheckBallDistance(){
if( Math.abs(x - TempX) >= BallDistance ){
State = false; //逻辑状态
DrawState = false;//绘画状态
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -