javascript - Loading effect inside canvas -


i developing game player can shoot enemies on hitting on space bar have scenario when player hit space loading bar should decreased till hit 0 , regenerate till hit 100. when regenerate player can shoot again having problem in doing scenario.

the code :

var charge=100 var player = {         x: 225,         y: 430,         width: 50,         height: 50,         image: "",         speed: 6,         life: 3,         middpoint: 25,         playercanshoot: true,         draw: function () {             canvas.drawimage(this.image, this.x, this.y, this.width, this.height);         },         shoot: function () {             bullets.push(playerbullets({ speed: 20, x: this.x + this.middpoint, y: this.y }));             var x = setinterval(function () {                 charge = charge - 20;             }, 500);             if (charge == 0){                 clearinterval(x); // when charge 0                 var y=setinterval(function(){                 charge=charge+20;                },500);             }             if(charge==100)              {                this.playercanshoot=true;              }         }     };    function update() {        if (keydown.space && player.playercanshoot){                 player.shoot();                 }      } 


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -