⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commonmovestrategy.java

📁 前段时间帮同学写了个简单动画程序:“贪食蛇的原型”
💻 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 + -