Skip to content

Commit

Permalink
Drop at Router functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeb16157 committed Dec 6, 2020
1 parent 6744eae commit 70c1102
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 5 additions & 2 deletions js/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ function animatePacket(packets, allEntities) {
//console.log(sliderVal);
//console.log(iterations);
for (let packet of packets) {
var dxCompute = (packet.x - packet.nextEntity.x) / iterations;
packet.dx = dxCompute;
packet.dxX = (packet.x - packet.nextEntity.x) / iterations;
packet.dxY = (packet.y - packet.nextEntity.y) / iterations;
}

runSim(packets, allEntities);
Expand Down Expand Up @@ -161,8 +161,11 @@ async function startSimulation() {
ddd.garbage = garbage;
router.nextEntity = ddd;
}

let server = new Server(1200, y, router, packetsPerTimeUnit);

client.nextEntity = server;

garbage.nextEntity = server;
garbage.packetsPerTimeUnit = 1;

Expand Down
11 changes: 4 additions & 7 deletions js/packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export class Packet{
// Animation instance variables
this.x = x;
this.y = y;
this.dx;
this.dxY;
this.dxX;
this.radius = radius;
this.nextEntity;
this.ctx = ctx;
Expand Down Expand Up @@ -34,12 +35,8 @@ export class Packet{
this.done = true;
return;
}
if (this.dropped == true) {
this.x -= this.dx;
this.y -= this.dx;
} else {
this.x -= this.dx;
}
this.x -= this.dxX;
this.y -= this.dxY;

this.draw();
}
Expand Down

0 comments on commit 70c1102

Please sign in to comment.