function init(){
cvs = document.getElementById('mycanvas');
// Setting the height and width of canvas
W = cvs.width = 1252;
H = cvs.height = 516;
// Getting the context of canvas
pen = cvs.getContext('2d');
// Initially setting the variable to false
game_over = false;
// Creating the enemies object with
// coordinates x y width(w) height(h)
// and speed
e1 = {
x:200,
y:50,
w:80,
h:80,
speed:20,
};
e2 = {
x:450,
y:150,
w:80,
h:80,
speed:35,
};
e3 = {
x:700,
y:300,
w:80,
h:80,
speed:40,
};
e4 = {
x:900,
y:100,
w:80,
h:80,
speed:30,
};
// Array of enemies
enemy = [e1, e2, e3, e4];
// Creating the player object
player = {
x:20,
y:H/2,
w:110,
h:110,
speed:30,
health:100,
moving: "false"
}
// Creating the vaccine gem
gem = {
x:W-150,
y:H/2,
w:150,
h:150,
}
// The main part lets move the player
// using event mouse down and stop
//using mouse up
cvs.addEventListener('mousedown', function(){
console.log("Mouse Pressed");
player.moving = true;
});
cvs.addEventListener('mouseup', function(){
console.log("Mouse Released");
player.moving = false;
});
}