Commit 96c11bac authored by haiyoucuv's avatar haiyoucuv

init

parent 70dcb203
......@@ -79,6 +79,7 @@ export class FoodManger extends Component {
*/
check() {
const { total, max } = this;
console.log(total, max);
for (let i = total; i < max; i++) {
this.add();
}
......
......@@ -562,14 +562,17 @@ export class Snake extends Component {
this.clearPropEffect()
const len = this.bodyArr.length;
const foodArr = this.bodyArr.map((body) => {
const foodArr = this.bodyArr.map((body, i) => {
body.removeFromParent();
bodyPool.put(body);
if (body.position.x > 99999) return;
if (i % 2 == 1) return;
return {
x: body.position.x + math.randomRange(-10, 10),
y: body.position.y + math.randomRange(-10, 10),
energy: ~~(this.energy / 2 / len),
energy: ~~(this.energy / len),
};
});
this.bodyArr.length = 0;
......
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