This commit is contained in:
leandro-rdz 2023-11-14 17:16:54 +01:00
commit e5a274496c
4 changed files with 19 additions and 10 deletions

BIN
assets/body.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 B

View file

@ -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))

View file

@ -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)
}

View file

@ -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();