Browse Source

player: draw path as line

master
Garrit Franke 3 years ago
parent
commit
702e68b1cd
Signed by: garrit
GPG Key ID: 65586C4DDA55EA2C
  1. 12
      src/components/Game.js

12
src/components/Game.js

@ -73,13 +73,21 @@ export default (props) => {
let currentPos = { ...initialPos };
// Draw initial position
p5.ellipse(currentPos.x * stepX, currentPos.y * stepY, 10, 10);
p5.ellipse(currentPos.x * stepX, currentPos.y * stepY, 5, 5);
for (let pos of playerPath) {
const previous = { ...currentPos };
currentPos.x += pos.x;
currentPos.y += pos.y;
p5.ellipse(currentPos.x * stepX, currentPos.y * stepY, 10, 10);
p5.push();
p5.stroke(150);
p5.line(previous.x * stepX, previous.y * stepY, currentPos.x * stepX, currentPos.y * stepY);
p5.pop();
p5.ellipse(currentPos.x * stepX, currentPos.y * stepY, 5, 5);
}
p5.pop();

Loading…
Cancel
Save