This commit is contained in:
Baptiste 2023-12-07 16:29:34 +01:00
parent 84794fe5c3
commit dbb0e87054
3 changed files with 109 additions and 43 deletions

View file

@ -194,12 +194,14 @@ class Circle
class Car
{
constructor(Renderer, x, y)
constructor(Renderer, x, y, type, dir, angle)
{
this.type=type // 0 circule à droite vers le haut
// 1 circule vers le bas
this.x=x;
this.y=y;
this.dir=1;
this.angle=0;
this.dir=dir;
this.angle=angle;
this.tick=1;
this.Renderer=Renderer;
}
@ -230,6 +232,63 @@ class Car
ChangeDirection()
{
if(this.type == 1) {
if(this.x==1247 && this.y==36) {
this.dir=3
this.angle=-Math.PI
} else if(this.x==430 && this.y==36) {
this.dir=4
this.angle=Math.PI/2
} else if(this.x==430 && this.y==330) {
//tourner à droite
this.dir=1
this.angle=0
} else if(this.x==607 && this.y==330) {
if(this.pseudoaleatoire()>5) {
//vers le bas
this.dir=4
this.angle=Math.PI/2
}
} else if(this.x==1247 && this.y==330) {
//vers le bas
this.dir=4
this.angle=Math.PI/2
} else if(this.x==607 && this.y==551) {
//vers la gauche
this.dir=3
this.angle=Math.PI
} else if(this.x==190 && this.y==551) {
//vers le bas
this.dir=4
this.angle=Math.PI/2
} else if(this.x==190 && this.y==877) {
//vers la droite
this.dir=1
this.angle=0
} else if(this.x==907 && this.y==877) {
//vers la droite
this.dir=4
this.angle=Math.PI/2
} else if(this.x==1247 && this.y==550) {
if(this.pseudoaleatoire()>5) {
//vers la gauche
this.dir=3
this.angle=Math.PI
}
} else if(this.x==910 && this.y==550) {
//vers le bas
this.dir=4
this.angle=Math.PI/2
} else if(this.x==1247 && this.y==840) {
//vers la gauche
this.dir=3
this.angle=Math.PI
} else if(this.x==907 && this.y==840) {
//vers le bas
this.dir=4
this.angle=Math.PI/2
}
} else {
if(this.x == 1280 && this.y==75) {
this.dir=2
this.y=60
@ -278,3 +337,4 @@ class Car
}
}
}
}

View file

@ -11,7 +11,13 @@ function CookiePseudo() {
Renderer = new Render("canvas", "./assets/map/map7_recadr.png");
LB = new LeaderBoard("canvas");
cars = [new Car(Renderer, 220, 75),new Car(Renderer, 500, 75),new Car(Renderer, 900,75),new Car(Renderer, 228,587),new Car(Renderer, 947,587)]
cars = [new Car(Renderer, 220, 75, 0, 1, 0),
new Car(Renderer, 500, 75, 0, 1, 0),
new Car(Renderer, 900,75, 0, 1, 0),
new Car(Renderer, 228,587, 0, 1, 0),
new Car(Renderer, 947,587, 0, 1, 0),
new Car(Renderer, 1247,600, 1, 4, Math.PI/2),
new Car(Renderer, 607,330, 1, 4, Math.PI/2)]
let Net = new Network("ws://129.151.227.50:8080?name="+CookiePseudo(), Renderer);