📄 boss.java
字号:
/*
* Boss.java
*
* Created on 2006年4月10日, 上午10:34
*
* 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 Boss extends Creature{
/*
* 参数
*/
private int Vx;//水平速度
public int Blood; //怪物的生命值
public int Number; //怪物的生命值
/** Creates a new instance of Boss */
public Boss(int x, int y, int WalkDir, Sprite ImageL, Sprite ImageR ,int blood) {
super(x, y, WalkDir, ImageL, ImageR);
//添加攻击
AttackState = 0;
AttackFrame = 0;
AttackStartFrame = 0;
AttackEndFrame = 1;
//帧的宽,高
frameWidth = 40;
frameHeight = 66;
//状态
State = true; //逻辑状态
DrawState = true;//绘画状态
//速度
Vx = 1;
//血
Blood = blood;
}
//过程更新
public void Process(int TickCount)
{
Move(WalkDir);
ChangeDir();
if(Number > 10){
Attack();
AttackProc();
Number = 0;
}
Number++;
}
//移动
private void Move(int WalkDir){
switch(WalkDir){
case 0:
//水平
x = x - Vx;
break;
case 1:
//水平
x = x + Vx;
break;
}
}
//改变方向
private void ChangeDir(){
if( x < 60){
WalkDir = 1;
}
if(x > 120){
WalkDir = 0;
}
}
public void Attack()
{
//处理动作
if(0 == AttackState){
AttackState = 1;
AttackFrame = 0;
}
}
//攻击过程
private void AttackProc(){
if(1 == AttackState){
//处理动作
Action = (0 == AttackFrame) ? AttackStartFrame : AttackEndFrame;
if(1 == AttackFrame){
AttackState = 0;
}
AttackFrame = 1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -