diff --git a/assets/body.png b/assets/body.png new file mode 100644 index 0000000..ce04dab Binary files /dev/null and b/assets/body.png differ diff --git a/class.js b/class.js index 53dd1e8..32a3f88 100644 --- a/class.js +++ b/class.js @@ -4,11 +4,13 @@ const playerSize = 10.; class Player { - constructor (x,y,id) + constructor (id,x,y,name) { + this.name=name; this.x=x; this.y=y; this.id=id; + this.visibleDir=1; this.dir=0;//0=standStill //1=North //2=North-East @@ -31,6 +33,13 @@ class Player //this.reset() } } + + + + get angle() + { + return (this.visibleDir-1)*3.1415926535/8.; + } } function dist(A,B) @@ -69,13 +78,6 @@ class Bullet return; } - /*squares.forEach(square => { - if (collideSquare(this,square)) - { - this.deleted=true; - break; - } - });*/ for(let square in squares) { if(square.collide(this)) diff --git a/game.js b/game.js index af36d77..9101c8c 100644 --- a/game.js +++ b/game.js @@ -3,5 +3,7 @@ setInterval(game); function game() { Renderer = new Render("canvas") - Renderer.AddPlayer(3, 5, ) + let rubiks = new Player(1, 100, 50, "rubiks") + console.log(rubiks) + Renderer.AddPlayer(rubiks) } \ No newline at end of file diff --git a/render.js b/render.js index cb32698..20a4efc 100644 --- a/render.js +++ b/render.js @@ -2,13 +2,18 @@ class Render { constructor(id) { this.canvas = document.getElementById(id) this.ctx = canvas.getContext("2d") - + this.players = [] this.ReloadAff() } + AddPlayer(id, pseudo, x, y, angle) { + this.players[id] = (id, pseudo, x, y, angle) + } + ReloadAff() { this.ctx.fillStyle = "red" this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height); + /*this.ctx.stokeStyle = "black" this.ctx.lineWidth = 1; ctx.beginPath();