Arnaud
ambigipathyv ago%!(EXTRA string=1 year)
parent 30d9e5bba7
commit 4f362e00cc
  1. 0
      js/API/API.js
  2. 41
      js/Render/renderer.js
  3. 28
      js/main.js

@ -0,0 +1,41 @@
class renderer {
constructor(canvas) {
this.canvas = canvas;
this.ctx = canvas.getContext("2d");
this.waypoints = [];
this.ships = [];
}
drawSystem() {
const canvas = document.getElementById("canvas");
let w = canvas.width;
let h = canvas.height;
const ctx = canvas.getContext("2d");
this.waypoints.forEach(waypoint => {
switch (waypoint.type) {
case "PLANET":
drawWaypoint(waypoint, ctx, w/2, h/2, 'green');
break;
case "ASTEROID":
drawWaypoint(waypoint, ctx, w/2, h/2, 'blue');
break;
case "GAS_GIANT":
drawWaypoint(waypoint, ctx, w/2, h/2, 'red');
break;
}
});
}
drawShips() {
}
drawWaypoint(wayPoint, ctx, w, h, color) {
ctx.beginPath();
ctx.fillStyle = color;
ctx.arc(wayPoint.x/offset.x + w, wayPoint.y/offset.y + h, 1, 0, 2 * Math.PI);
ctx.fill();
}
}

@ -82,32 +82,4 @@ function getSystem(system) {
});
}
function drawSystem(wayPoints) {
const canvas = document.getElementById("canvas");
let w = canvas.width;
let h = canvas.height;
const ctx = canvas.getContext("2d");
wayPoints.forEach(wayPoint => {
switch (wayPoint.type) {
case "PLANET":
drawWaypoint(wayPoint, ctx, w/2, h/2, 'green');
break;
case "ASTEROID":
drawWaypoint(wayPoint, ctx, w/2, h/2, 'blue');
break;
case "GAS_GIANT":
drawWaypoint(wayPoint, ctx, w/2, h/2, 'red');
break;
}
});
}
function drawWaypoint(wayPoint, ctx, w, h, color) {
ctx.beginPath();
ctx.fillStyle = color;
ctx.arc(wayPoint.x/offset.x + w, wayPoint.y/offset.y + h, 1, 0, 2 * Math.PI);
ctx.fill()
}
getAgent();

Loading…
Cancel
Save