Commit 528e7534 authored by haiyoucuv's avatar haiyoucuv

init

parent b2d1c691
......@@ -123,11 +123,12 @@ export class MainGame extends Scene {
wallRight.getComponent(UITransform).height = Global.MAP_HEIGHT;
this.player.init({
// initEnergy: 100
// initEnergy: 10000
});
// 初始化食物和NPC
this.fondManger.init(this.maxFood);
// this.fondManger.init(2000);
this.initAnimal(this.maxAnimal);
// this.initAnimal(1);
......
......@@ -92,7 +92,6 @@ export class Snake extends Component {
const hw = this.imgHead.originalSize.width;
const bw = this.imgBody1.originalSize.width;
// this.head.getComponent(UITransform).anchorX = (bw / 2) / hw;
this.head.getComponent(UITransform).anchorX = (bw / 2) / hw;
......@@ -177,9 +176,11 @@ export class Snake extends Component {
// 能量与成长
lastRemaining = 0;
private addEnergy(value: number) {
console.log(this.energy, value);
this.energy += value;
const growthThreshold = Math.floor(4 * this.scale);
value += this.lastRemaining;
while (value >= growthThreshold) {
......@@ -190,6 +191,8 @@ export class Snake extends Component {
}
}
console.log(this.energy, this.scale, this.energy / this.bodyArr.length);
this.lastRemaining = value;
// this.speed = 600 * this.scale;
......@@ -309,8 +312,10 @@ export class Snake extends Component {
const mapHalfWidth = Global.MAP_WIDTH / 2;
const mapHalfHeight = Global.MAP_HEIGHT / 2;
if (
newHeadPos.x <= -mapHalfWidth || newHeadPos.x >= mapHalfWidth ||
newHeadPos.y <= -mapHalfHeight || newHeadPos.y >= mapHalfHeight
newHeadPos.x <= -mapHalfWidth
|| newHeadPos.x >= mapHalfWidth
|| newHeadPos.y <= -mapHalfHeight
|| newHeadPos.y >= mapHalfHeight
) {
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