From b977d52648fb2fa05ba4720bddafbccba2297553 Mon Sep 17 00:00:00 2001 From: Simon Giesel Date: Tue, 20 Jun 2017 13:52:21 +0200 Subject: [PATCH] Test collision with larger barriers --- index.html | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 324a291..fde60ec 100644 --- a/index.html +++ b/index.html @@ -38,11 +38,11 @@ var _COLOR_GRASS = '#388E3C', ctx = $('canvas')[0].getContext('2d') staticctx = $('canvas')[1].getContext('2d') init() - drawBorder(23+5, 10, 500-10, 5) - drawBorder(23, 10+5, 5, 500-10) + drawBorder(23, 10, 500, 10) + drawBorder(23, 10, 10, 500) drawBorder(23+200, 10+70, 50, 50) - drawBorder(23+5, 500+10-5, 500-10, 5) - drawBorder(500+23-5, 10+5, 5, 500-10) + drawBorder(23, 500+10-10, 500, 10) + drawBorder(500+23-10, 10, 10, 500) drawHole(432, 366) setInterval(animLoop, 5) @@ -130,6 +130,12 @@ var _COLOR_GRASS = '#388E3C', ctx.fillStyle = _COLOR_BALL ctx.fill() ctx.closePath() + //DEBUG + ctx.beginPath() + ctx.arc(x, y, 1, 0, Math.PI*2) + ctx.fillStyle = 'black' + ctx.fill() + ctx.closePath() } 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]){ console.log('left < 0'); bVec = [Math.abs(bVec[0]), bVec[1]] @@ -212,8 +213,10 @@ var _COLOR_GRASS = '#388E3C', } - if($.inArray(true, coll) > -1) + if($.inArray(true, coll) > -1){ + console.log(coll) console.log(bVec); + } } /** CLASSES **/