Fixed collision detection

This commit is contained in:
Thomas
2020-08-28 16:09:47 +02:00
parent cec5fca5c4
commit 8add12d4c3
5 changed files with 23 additions and 8 deletions

View File

@@ -93,9 +93,10 @@ export default {
this.context.stroke()
},
renderDebug (player) {
this.context.beginPath()
const canvasX = this.canvas.width / 2
const canvasY = this.canvas.height / 2
/*
this.context.beginPath()
this.context.lineTo(canvasX, canvasY)
this.context.lineTo(this.mouse.x, this.mouse.y)
this.context.lineWidth = 1
@@ -111,12 +112,6 @@ export default {
this.context.strokeStyle = 'yellow'
this.context.stroke()
this.context.beginPath()
this.context.arc(this.mouse.x, this.mouse.y, 25, 0, 2 * Math.PI, false)
this.context.lineWidth = 1
this.context.strokeStyle = 'yellow'
this.context.stroke()
const canvasX2 = this.canvas.width / 2
const canvasY2 = this.canvas.height / 2
this.context.beginPath()
@@ -124,11 +119,18 @@ export default {
this.context.lineWidth = 1
this.context.strokeStyle = 'purple'
this.context.stroke()
*/
this.context.fillText('player x: ' + player.x + ' y:' + player.y, 10, 10)
this.context.fillText('a:' + player.angle + ' a_t' + player.targetAngle, 10, 20)
this.context.fillText('canvasX: ' + canvasX + ' canvasY:' + canvasY, 10, 30)
this.context.fillText('walls: ' + player.walls.length, 10, 40)
this.context.beginPath()
this.context.arc(this.mouse.x, this.mouse.y, 25, 0, 2 * Math.PI, false)
this.context.lineWidth = 1
this.context.strokeStyle = player.color
this.context.stroke()
},
mouseEvent (event) {
var rect = this.canvas.getBoundingClientRect()