Commit e25b3082 authored by haiyoucuv's avatar haiyoucuv

init

parent 3cd61290
...@@ -357,7 +357,7 @@ export class Snake extends Component { ...@@ -357,7 +357,7 @@ export class Snake extends Component {
private readonly HISTORY_LENGTH = 10; // 增加历史点数量 private readonly HISTORY_LENGTH = 10; // 增加历史点数量
private readonly SEGMENT_SPACING = 6.3; // 增加节点间距 private readonly SEGMENT_SPACING = 6.3; // 增加节点间距
moveTime = 1 / 30; moveTime = 1 / 60;
totalTime = 0; totalTime = 0;
moveScale = 1; moveScale = 1;
...@@ -399,7 +399,7 @@ export class Snake extends Component { ...@@ -399,7 +399,7 @@ export class Snake extends Component {
this.positions.unshift(newHeadPos); this.positions.unshift(newHeadPos);
// 确保历史位置点足够多,以容纳所有身体节点 // 确保历史位置点足够多,以容纳所有身体节点
const requiredLength = this.bodyArr.length * space + 1; const requiredLength = this.bodyArr.length * space + 1;
if (this.positions.length > Math.max(requiredLength, this.HISTORY_LENGTH)) { if (this.positions.length > requiredLength) {
this.positions.pop(); this.positions.pop();
} }
...@@ -436,16 +436,16 @@ export class Snake extends Component { ...@@ -436,16 +436,16 @@ export class Snake extends Component {
} }
// 边界检查 // 边界检查
// const mapHalfWidth = Global.MAP_WIDTH / 2; const mapHalfWidth = Global.MAP_WIDTH / 2;
// const mapHalfHeight = Global.MAP_HEIGHT / 2; const mapHalfHeight = Global.MAP_HEIGHT / 2;
// if ( if (
// newHeadPos.x <= -mapHalfWidth newHeadPos.x <= -mapHalfWidth
// || newHeadPos.x >= mapHalfWidth || newHeadPos.x >= mapHalfWidth
// || newHeadPos.y <= -mapHalfHeight || newHeadPos.y <= -mapHalfHeight
// || newHeadPos.y >= mapHalfHeight || newHeadPos.y >= mapHalfHeight
// ) { ) {
// this.death(); this.death();
// } }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment