[verified] Snake 0.8: circular arena and larger 32px tiles
This commit is contained in:
+14
-1
@@ -8,7 +8,20 @@ function rule(name) {
|
||||
return Object.fromEntries(m[1].split(';').filter(s=>s.includes(':')).map(s=>s.trim().split(/:\s*/)))
|
||||
}
|
||||
function px(r,k) { assert.match(r[k] || '', /^\d+px$/, k); return Number(r[k].slice(0,-2)) }
|
||||
for (const name of ['board','hud','footer','overlay']) {
|
||||
const arena = require('../src/common/snake.js').ARENA
|
||||
assert.equal(px(rule('seg'),'width'),arena.cell)
|
||||
assert.equal(px(rule('seg'),'height'),arena.cell)
|
||||
assert.equal(px(rule('food'),'width'),arena.cell)
|
||||
const board=rule('board')
|
||||
assert.equal(px(board,'width'),arena.radius*2)
|
||||
assert.equal(px(board,'height'),arena.radius*2)
|
||||
assert.equal(px(board,'left')+arena.radius,233)
|
||||
assert.equal(px(board,'top')+arena.radius,233)
|
||||
for(const c of arena.cells) for(const name of ['hud','footer']) {
|
||||
const r=rule(name), x=arena.offset+c.x*arena.cell,y=arena.offset+c.y*arena.cell
|
||||
assert.ok(x+arena.cell<=px(r,'left') || x>=px(r,'left')+px(r,'width') || y+arena.cell<=px(r,'top') || y>=px(r,'top')+px(r,'height'), 'legal cell never overlaps '+name)
|
||||
}
|
||||
for (const name of ['hud','footer','overlay']) {
|
||||
const r = rule(name), x=px(r,'left'), y=px(r,'top'), w=px(r,'width'), h=px(r,'height')
|
||||
const dy = Math.max(Math.abs(y-233), Math.abs(y+h-233))
|
||||
const chord = 2*Math.sqrt(233*233-dy*dy)
|
||||
|
||||
Reference in New Issue
Block a user