rm push/pop
This commit is contained in:
@@ -91,12 +91,12 @@ function reset_game() {
|
||||
var cy = floor(gridH / 2)
|
||||
var wp = null
|
||||
for (i = 0; i < 3; i++) {
|
||||
push(snake_pos, {x: cx - i, y: cy})
|
||||
snake_pos[] = {x: cx - i, y: cy}
|
||||
wp = grid_to_world(cx - i, cy)
|
||||
push(snake_shapes, shape.rect({
|
||||
snake_shapes[] = shape.rect({
|
||||
pos: {x: wp.x, y: wp.y}, width: cellSize - 2, height: cellSize - 2,
|
||||
fill: {r: 0, g: 1, b: 0.3, a: 1}, plane: 'game'
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
dir = {x: 1, y: 0}
|
||||
@@ -166,7 +166,7 @@ core.start({
|
||||
var old_wp = grid_to_world(snake_pos[0].x, snake_pos[0].y)
|
||||
var new_wp = grid_to_world(hx, hy)
|
||||
var new_pos = [{x: hx, y: hy}]
|
||||
for (i = 0; i < length(snake_pos); i++) push(new_pos, snake_pos[i])
|
||||
for (i = 0; i < length(snake_pos); i++) new_pos[] = snake_pos[i]
|
||||
snake_pos = new_pos
|
||||
var head = shape.rect({
|
||||
pos: {x: old_wp.x, y: old_wp.y}, width: cellSize - 2, height: cellSize - 2,
|
||||
@@ -175,7 +175,7 @@ core.start({
|
||||
// Smooth tween from old position to new position
|
||||
tw.tween(head.pos).to({x: new_wp.x, y: new_wp.y}, move_interval).ease(ease.linear)
|
||||
var new_shapes = [head]
|
||||
for (i = 0; i < length(snake_shapes); i++) push(new_shapes, snake_shapes[i])
|
||||
for (i = 0; i < length(snake_shapes); i++) new_shapes[] = snake_shapes[i]
|
||||
snake_shapes = new_shapes
|
||||
|
||||
// Eat apple?
|
||||
@@ -185,9 +185,9 @@ core.start({
|
||||
spawn_apple()
|
||||
} else {
|
||||
// Remove tail
|
||||
tail = pop(snake_shapes)
|
||||
tail = snake_shapes[]
|
||||
tail.destroy()
|
||||
pop(snake_pos)
|
||||
snake_pos[]
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user