Sunday 3 February 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...