Salīdzināt revīzijas

..

Nav kopīgu revīziju. Atzariem "87d078a34d04b9dd7c99a63dc4a04702115f7bda" un "a4c8e32a265308baa70257d31d925ddf9ef94983" ir pilnībā atšķirīga izmaiņu vēsture.

6 mainīti faili ar 19 papildinājumiem un 41 dzēšanām

Bināro failu nav iespējams attēlot.

Parādīt failu

@ -7,6 +7,9 @@ const bulletSpeed=playerSpeed*2;
const halfSqrtTwo=0.70710678118; const halfSqrtTwo=0.70710678118;
const defaulthealth=10.; const defaulthealth=10.;
let sound = new Sound("./assets/sounds/");
sound.loadSounds();
class Player class Player
{ {
constructor (id,x,y,name, dir) constructor (id,x,y,name, dir)
@ -111,7 +114,7 @@ class Player
class Bullet class Bullet
{ {
constructor (x,y,dx,dy,id, sound) constructor (x,y,dx,dy,id)
{ {
sound.shoot(); sound.shoot();
this.x=x; this.x=x;
@ -195,9 +198,8 @@ class Circle
class Car class Car
{ {
constructor(Renderer, type, spawn, sound) constructor(Renderer, type, spawn)
{ {
this.sound=sound
this.type=type // 0 circule vers le haut this.type=type // 0 circule vers le haut
// 1 circule vers le bas // 1 circule vers le bas
@ -213,8 +215,6 @@ class Car
this.angle=-Math.PI/2; this.angle=-Math.PI/2;
} }
this.drift=0;
this.spawn=spawn this.spawn=spawn
this.tick=0; this.tick=0;
@ -227,12 +227,7 @@ class Car
{ {
let cx=this.x-carSize/2; let cx=this.x-carSize/2;
let cy=this.y-carSize/2; let cy=this.y-carSize/2;
let collide = (cx<=x && x<=cx+carSize && cy<=y && y<=cy+carSize); return (cx<=x && x<=cx+carSize && cy<=y && y<=cy+carSize);
if(collide) {
this.sound.drift()
this.drift=300;
}
return collide
} }
Update() Update()
@ -257,13 +252,8 @@ class Car
this.y=this.y+this.tick this.y=this.y+this.tick
break; break;
} }
if(this.drift > 0) {
this.Renderer.RenderCar(this.x,this.y, this.angle+90)
this.drift--
} else {
this.Renderer.RenderCar(this.x,this.y, this.angle) this.Renderer.RenderCar(this.x,this.y, this.angle)
} }
}
pseudoaleatoire() { pseudoaleatoire() {
return Math.floor(Date.now()/1000)%10 return Math.floor(Date.now()/1000)%10

Parādīt failu

@ -11,15 +11,13 @@ function CookiePseudo() {
Renderer = new Render("canvas", "./assets/map/map7_recadr.png"); Renderer = new Render("canvas", "./assets/map/map7_recadr.png");
LB = new LeaderBoard("canvas"); LB = new LeaderBoard("canvas");
let sound = new Sound("./assets/sounds/"); cars = [new Car(Renderer, 0, 0),
sound.loadSounds(); new Car(Renderer, 0, 7),
cars = [new Car(Renderer, 0, 0, sound), new Car(Renderer, 1, 7),
new Car(Renderer, 0, 7, sound), new Car(Renderer, 1, 13),
new Car(Renderer, 1, 7, sound), new Car(Renderer, 1, 14),
new Car(Renderer, 1, 13, sound), new Car(Renderer, 0, 15)]
new Car(Renderer, 1, 14, sound), let Net = new Network("ws://129.151.227.50:8080?name="+CookiePseudo(), Renderer);
new Car(Renderer, 0, 15, sound)]
let Net = new Network("ws://129.151.227.50:8080?name="+CookiePseudo(), sound);
let playerId = null; //id of client player let playerId = null; //id of client player
@ -27,7 +25,7 @@ let players = [];
let bullets = []; let bullets = [];
let player = null; let player = null;
Inp = new Input("canvas", Net,Renderer, sound); Inp = new Input("canvas", Net,Renderer);
playerId=Net.playerId; playerId=Net.playerId;
player=Net.clientPlayer; player=Net.clientPlayer;

Parādīt failu

@ -1,5 +1,5 @@
class Input { class Input {
constructor(id, net,renderer, sound) { constructor(id, net,renderer) {
this.keysDown = new Set() this.keysDown = new Set()
this.dir = 0; this.dir = 0;
this.player=null; this.player=null;
@ -23,7 +23,7 @@ class Input {
let dx = this.mouseX-this.player.x; let dx = this.mouseX-this.player.x;
let dy = this.mouseY-this.player.y; let dy = this.mouseY-this.player.y;
let norm = Math.sqrt(dx*dx+dy*dy); let norm = Math.sqrt(dx*dx+dy*dy);
let b = new Bullet(this.player.x,this.player.y,dx/norm,dy/norm,this.player.id, sound); let b = new Bullet(this.player.x,this.player.y,dx/norm,dy/norm,this.player.id);
this.bullets.push(b); this.bullets.push(b);
this.renderer.addBullet(b); this.renderer.addBullet(b);

Parādīt failu

@ -1,5 +1,5 @@
class Network{ class Network{
constructor(adress, bulletsound){ constructor(adress){
this.adress = adress; this.adress = adress;
this.connected = false; this.connected = false;
@ -10,7 +10,6 @@ class Network{
this.playersToUpdate = []; this.playersToUpdate = [];
this.bulletsToAdd = []; this.bulletsToAdd = [];
this.deathToAdd = []; this.deathToAdd = [];
this.sound=bulletsound;
} }
message(data){ message(data){
@ -37,8 +36,7 @@ class Network{
this.playersToRemove.push(data.data.id); this.playersToRemove.push(data.data.id);
break; break;
case "newBullet": case "newBullet":
console.log(this.sound) this.bulletsToAdd.push(new Bullet(data.data.x,data.data.y,data.data.dx,data.data.dy,data.data.id));
this.bulletsToAdd.push(new Bullet(data.data.x,data.data.y,data.data.dx,data.data.dy,data.data.id, this.sound));
break; break;
case "died": case "died":
console.log("player",data.data.id,"was killed by",data.data.killerId); console.log("player",data.data.id,"was killed by",data.data.killerId);

Parādīt failu

@ -7,8 +7,6 @@ class Sound{
console.log(this.assetsUrl + "shoot.mp3") console.log(this.assetsUrl + "shoot.mp3")
this.shootSound = new Audio(this.assetsUrl + "shoot.mp3"); this.shootSound = new Audio(this.assetsUrl + "shoot.mp3");
this.shootSound.type = "audio/mp3"; this.shootSound.type = "audio/mp3";
this.driftsound = new Audio(this.assetsUrl + "drift.mp3");
this.driftsound.type = "audio/mp3";
} }
shoot(){ shoot(){
@ -16,10 +14,4 @@ class Sound{
this.shootSound.currentTime=0; this.shootSound.currentTime=0;
this.shootSound.play() this.shootSound.play()
} }
drift(){
this.driftsound.pause()
this.driftsound.currentTime=0;
this.driftsound.play()
}
} }