Test collision with larger barriers
This commit is contained in:
parent
e06705918c
commit
b977d52648
1 changed files with 14 additions and 11 deletions
25
index.html
25
index.html
|
@ -38,11 +38,11 @@ var _COLOR_GRASS = '#388E3C',
|
||||||
ctx = $('canvas')[0].getContext('2d')
|
ctx = $('canvas')[0].getContext('2d')
|
||||||
staticctx = $('canvas')[1].getContext('2d')
|
staticctx = $('canvas')[1].getContext('2d')
|
||||||
init()
|
init()
|
||||||
drawBorder(23+5, 10, 500-10, 5)
|
drawBorder(23, 10, 500, 10)
|
||||||
drawBorder(23, 10+5, 5, 500-10)
|
drawBorder(23, 10, 10, 500)
|
||||||
drawBorder(23+200, 10+70, 50, 50)
|
drawBorder(23+200, 10+70, 50, 50)
|
||||||
drawBorder(23+5, 500+10-5, 500-10, 5)
|
drawBorder(23, 500+10-10, 500, 10)
|
||||||
drawBorder(500+23-5, 10+5, 5, 500-10)
|
drawBorder(500+23-10, 10, 10, 500)
|
||||||
drawHole(432, 366)
|
drawHole(432, 366)
|
||||||
setInterval(animLoop, 5)
|
setInterval(animLoop, 5)
|
||||||
|
|
||||||
|
@ -130,6 +130,12 @@ var _COLOR_GRASS = '#388E3C',
|
||||||
ctx.fillStyle = _COLOR_BALL
|
ctx.fillStyle = _COLOR_BALL
|
||||||
ctx.fill()
|
ctx.fill()
|
||||||
ctx.closePath()
|
ctx.closePath()
|
||||||
|
//DEBUG
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.arc(x, y, 1, 0, Math.PI*2)
|
||||||
|
ctx.fillStyle = 'black'
|
||||||
|
ctx.fill()
|
||||||
|
ctx.closePath()
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawBracket() {
|
function drawBracket() {
|
||||||
|
@ -188,12 +194,7 @@ var _COLOR_GRASS = '#388E3C',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if($.inArray(true, coll) > -1)
|
|
||||||
console.log(coll);
|
|
||||||
// if(coll[0] || coll[2])
|
|
||||||
// bVec = [-bVec[0], bVec[1]]
|
|
||||||
// if(coll[1] || coll[3])
|
|
||||||
// bVec = [bVec[0], -bVec[1]]
|
|
||||||
if(coll[0]){
|
if(coll[0]){
|
||||||
console.log('left < 0');
|
console.log('left < 0');
|
||||||
bVec = [Math.abs(bVec[0]), bVec[1]]
|
bVec = [Math.abs(bVec[0]), bVec[1]]
|
||||||
|
@ -212,9 +213,11 @@ var _COLOR_GRASS = '#388E3C',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($.inArray(true, coll) > -1)
|
if($.inArray(true, coll) > -1){
|
||||||
|
console.log(coll)
|
||||||
console.log(bVec);
|
console.log(bVec);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** CLASSES **/
|
/** CLASSES **/
|
||||||
function Border(x, y, width, height) {
|
function Border(x, y, width, height) {
|
||||||
|
|
Reference in a new issue