I'm new to javascript, I've got some issues.
I want to create an instance of the object Obstacle inside the js5.js file, but I keep getting this error message:
Uncaught ReferenceError: Obstacle is not defined at window.onload
Here's what I've done, I shouldn't modify the file where the Obstacle is created, I have to work on the js5.js file.
js5.js file:
window.onload = function(){
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var posX = 30;
var posY = 375;
var posyInit = 375;
var theta = 0;
var pas = 0;
var ligne = 2;
var droite = true;
var compteur = 0;
var o1 = new Obstacle(0,0,27,27);
var o2 = new Obstacle(184,84,134,67);
var toto = new Array(o1,o2);
obstacle.js:
function Obstacle (p_x,p_y,p_largeur,p_hauteur) {
this.x = p_x;
this.y = p_y;
this.largeur = p_largeur;
this.hauteur = p_hauteur;
Obstacle.prototype.notAllowed = function(a,b){
if (a>=this.x&&a<=this.x+this.largeur&&b>=this.y&&b<=this.y+this.hauteur)
return true;
else
return false;
};
Thanks for your help :)