reworked levels...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-04-21 20:49:39 +03:00
parent 971b3bf711
commit d08c11b5ef
2 changed files with 27 additions and 17 deletions

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# Timestamp: 20170421203054 # Timestamp: 20170421204925
CACHE: CACHE:
simplesnake.html simplesnake.html

View File

@ -246,7 +246,7 @@ var Snake = {
point = this.normalize_point(point || this.random_point) point = this.normalize_point(point || this.random_point)
var x = point.x var x = point.x
var y = point.y var y = point.y
length = length || 1 length = length || Math.random() * this.field_size.width
while(length > 0){ while(length > 0){
var c = this._cells[x + y * this.field_size.width] var c = this._cells[x + y * this.field_size.width]
@ -406,18 +406,30 @@ function setup(snake, timer, size){
// levels... // levels...
var A = Math.round((size || snake.config.field_size)/8) var A = Math.round((size || snake.config.field_size)/8)
var RANDOM3_LEVEL = [ var Level = {
W3: [
[null, null, A*6], [null, null, A*6],
[null, null, A*6], [null, null, A*6],
[null, null, A*6], [null, null, A*6],
] ],
var HALVES_LEVEL = [ Halves: [
[null, null, A*8], [null, null, A*8],
] ],
var QUARTERS_LEVEL = [ Quarters: [
[null, 's', A*8], [null, 's', A*8],
[null, 'e', A*8], [null, 'e', A*8],
] ],
Random3: [[], [], []],
get random(){
var l = Object.keys(this)
.filter(function(e){ return e != 'random' })
do {
var level = this[l[ Math.round(Math.random()*l.length) ]]
} while(!(level instanceof Array))
return level
},
}
function showScore(color, age){ function showScore(color, age){
score = snake.__top_score = score = snake.__top_score =
@ -470,9 +482,7 @@ function setup(snake, timer, size){
}) })
// load level... // load level...
.level(RANDOM3_LEVEL) .level(Level.random)
//.level(HALVES_LEVEL)
//.level(QUARTERS_LEVEL)
// game events / meta game rules... // game events / meta game rules...
// reconstruct eaten apples... // reconstruct eaten apples...