From 1dd378518b5918210660931ec503ca10fc1d501f Mon Sep 17 00:00:00 2001 From: Atsuyo-INSA Date: Tue, 14 Nov 2023 17:10:20 +0100 Subject: [PATCH 1/2] SmallClassChanges --- class.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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)) From 6ad927571ade2faff30788daf366258bb34f3923 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Tue, 14 Nov 2023 17:11:05 +0100 Subject: [PATCH 2/2] player --- assets/body.png | Bin 0 -> 968 bytes game.js | 4 +++- render.js | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 assets/body.png diff --git a/assets/body.png b/assets/body.png new file mode 100644 index 0000000000000000000000000000000000000000..ce04dab17161b2b2a74228a587e7779d52e05384 GIT binary patch literal 968 zcmeAS@N?(olHy`uVBq!ia0vp^JwRN}!3HERPF?W?NU;<-L1ke-*Ho2px!T$GxcSDcYw@}7CW9Z-=5NRe| zt+W@otGw${jCuK&b8h~fxjW8$bk=B%+@5<|?7<@YoB9mNiV_|iY(haJ&TCz74iF#YC17y%ew3TVm~~$%{e4+YNvegvn+$tLQ=ie1}#N* z>n~~?)bWlm`IGrT@5+Iw`rhj;iJP|koMmLoXyGS4ozq$8q|EZ(N`oUoEx{(s4hnc1 z@?G5UVz2e%j5AG%yF}6?c!kr%+%5|Egx(h0_qM*((_l`YOr%?~LFx>H2?A$0xO^p> zBwZ(FaHOfQiXCJzmRg-5wVdZ*kA|TXC`8<*ZkeZ9onPAW{CWEI|MfLB5_>1P-M+S8 za{IcVnqcRDY zPM3H_F$ni;-n4wtF>SNU38(g1mQOCwx@DLsbN6M)7G(+b)aAL)pDnC3NWH(pA@9B8 zqm>!QTMWa@#FT4F_b7gj&`~zDIYs2$Tez%f4R=ZE$#~AsgGsot|pWZJK z)0WywJU={B?#wzT3st9^f@j_vEz%S{sonJQx^&1*i+h=zY7YYVM9+j&T(G>uQumA# zm?R}*KXf(yp0rA9*Ort+4o<)b<56K@<~&FN^AEEnyFoOs@Si)tT*lz(>gTe~DWM4f DHgSn; literal 0 HcmV?d00001 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();