commonmovestrategy.java~2~
来自「前段时间帮同学写了个简单动画程序:“贪食蛇的原型”」· JAVA~2~ 代码 · 共 19 行
JAVA~2~
19 行
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);//开始移动,注意:以后后会改变移动单元的当前运动方向. }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?