Sunday, February 3, 2019

javascript - My external JS file isn't loading

I followed Mozila's example on their web-site and tried to create a simple 2d game. Everything works fine. Then I decided to separate the code from the html page into a single js file. But for some unknown reason it isn't loaded into my html.
here's my html code:



    




Gamedev Canvas Workshop












and here is the beginning of the script file:



    var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
var ballRadius = 10;
var x = canvas.width/2;
var y = canvas.height-30;

var dx = 2;
var dy = -2;
var paddleHeight = 10;
var paddleWidth = 75;
var paddleX = (canvas.width-paddleWidth)/2;
var rightPressed = false;
var leftPressed = false;
var brickRowCount = 5;



Again everything works fine when I use inline script inside the html. But as soon as I try to separate the code and html - it fails. Any help?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...