1234567891011121314151617181920212223242526272829303132333435363738394041 |
- let stationPosition = {x: -150, y: 0};
- let stationTargetPosition = {x: -150, y: 0};
- sets.push({
- id: "station",
- setup: () => {
- if(!setsLoaded['station']) {
- buildStation();
- setsLoaded['station'] = true;
- }
- },
- update: (delta) => {
- updateStation(delta);
- },
- draw: (context, delta) => {
- drawStation(context, delta);
- },
- });
- function buildStation() {
- }
- function updateStation(delta) {
- if(stationPosition.x != stationTargetPosition.x) {
- stationPosition.x += (stationTargetPosition.x - stationPosition.x) / 30;
- }
- if(stationPosition.y != stationTargetPosition.y) {
- stationPosition.y += (stationTargetPosition.y - stationPosition.y) / 30;
- }
- }
- function drawStation(context, delta) {
- context.fillStyle = "grey";
- let radius = Math.min(canvas.width, canvas.height);
- context.beginPath();
- context.arc(- radius + stationPosition.x, stationPosition.y, radius, 0, 2 * Math.PI);
- context.fill();
- }
|