📄 commonmovestrategy.java
字号:
package com.cxlife.snake;import java.awt.Component;//这是个通用移动策略,对移动单元没有任何限制,但存在移动效果不是很好public class CommonMoveStrategy implements java.io.Serializable, com.cxlife.snake.MoveStrategy{ 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.move(pValue,pComponent);//开始移动,注意:以后后会改变移动单元的当前运动方向. }}//end procedure;}//end class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -