📄 defaultmovestrategy.java~3~
字号:
package com.cxlife.snake;
//当所有的移动单元大小相同时,采用这个移动测量,这样不会存在闪烁。
import java.awt.Component;
public class DefaultMoveStrategy implements com.cxlife.snake.MoveStrategy,
java.io.Serializable{
public void move(final Snake snake,final ISnake pValue,final Component pComponent){
if (pValue == null)
return ;
int last_direction = snake.next_direction;//记录上一个单元的当前运动方向.
int intLen = snake.getLen();
SnakeUnit su = null;
for(int i=0; i<intLen; i++){
su = (SnakeUnit)snake.unit_list.get(i);
su.setNext_direction(last_direction);
last_direction = su.curr_direction;//记录运动前的当前运动方向.
su.go(pValue,pComponent);//开始移动,注意:以后后会改变移动单元的当前运动方向.
// if (i == intLen - 1)
// pValue.clearUnit(su.left,su.top,su.width,su.height);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -