Итак, пару дней назад я попросил помощи и решил ее, но проблема вернулась, как только я сделал второй модуль и начал импортировать и экспортировать, какая-нибудь помощь?
HTML:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<canvas id='canvas' width=600 height=400></canvas>
<script type='module/javascript' src='main.js'></script>
<script type='module/javascript' src='classes/player.js'></script>
</body>
</html>
main.js:
import { Player } from 'classes/player.js';
var canvas = document.getElementById("canvas"),
c = canvas.getContext("2d"),
width = canvas.width,
height = canvas.height;
c.scale(1, -1);
c.translate(0, -width);
player.js:
export class Player {
constructor() {
this.cx = 100; //coordinates of the center for operations
this.cy = width / 2; //coordinates of the center for operations
this.x = this.cx - 25; //coordinates of the corner for drawing
this.y = this.cy + 25; //coordinates of the corner for drawing
this.w = 50;
this.h = 50;
}
show() {
c.fillRect(this.x, this.y, this.w, this.h);
}
}