station.js 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. let stationPosition = {x: -150, y: 0};
  2. let stationTargetPosition = {x: -150, y: 0};
  3. sets.push({
  4. id: "station",
  5. setup: () => {
  6. if(!setsLoaded['station']) {
  7. buildStation();
  8. setsLoaded['station'] = true;
  9. }
  10. },
  11. update: (delta) => {
  12. updateStation(delta);
  13. },
  14. draw: (context, delta) => {
  15. drawStation(context, delta);
  16. },
  17. });
  18. function buildStation() {
  19. }
  20. function updateStation(delta) {
  21. if(stationPosition.x != stationTargetPosition.x) {
  22. stationPosition.x += (stationTargetPosition.x - stationPosition.x) / 30;
  23. }
  24. if(stationPosition.y != stationTargetPosition.y) {
  25. stationPosition.y += (stationTargetPosition.y - stationPosition.y) / 30;
  26. }
  27. }
  28. function drawStation(context, delta) {
  29. context.fillStyle = "grey";
  30. let radius = Math.min(canvas.width, canvas.height);
  31. context.beginPath();
  32. context.arc(- radius + stationPosition.x, stationPosition.y, radius, 0, 2 * Math.PI);
  33. context.fill();
  34. }