I have looked through many other answers of this question unable to find an answer.
The issue seems to be that it isn't recognizing the World global in my game.js file.
The html file is ordered properly
<script src="js/world.js"></script>
<script src="js/game.js"></script>
IN world.js -- This constructor should work seeing as it is similiar to my other construcotrs
var World = function(){
var draw = function(ctx) {
ctx.drawImage(bg1, 100, 100);
};
};
IN game.js -- The culprit is likely here
Note that neither of these two functions below are nested in anything:
var World;
function init() {
// Declare the canvas and rendering context
canvas = document.getElementById("gameCanvas");
ctx = canvas.getContext("2d");
localPlayer = new Player(startX, startY); //WORKS CORRECTLY
World = new World(); //SHOULD ALSO WORK CORRECTLY
......................
outside of the init function is
function draw() {
// Wipe the canvas clean
ctx.clearRect(0, 0, canvas.width, canvas.height);
World.draw(ctx);
// Draw the local player
// Draw the remote players
var i;
for (i = 0; i < remotePlayers.length; i++) {
remotePlayers[i].draw(ctx);
};
localPlayer.draw(ctx);
};
At World.draw(ctx) is where I am getting the error
Uncaught TypeError: Object [object Object] has no method 'draw' game.js:202 draw
If you need any more details I'd be happy to oblige. I would have posted all of my code except that it is pretty big.