Search posts, tags, users, and pages
Sudarshan Rai
Software Developer
The Game Loop Note: While the architecture discussed here is a classic and widely accepted foundation, it is not the only way to build a game. Software engineering offers many patterns, and as your g
Challenge of bounce to-fro: modify in update() method
if(this.x===0){ this.count--; } if(this.x===canvas.width){ this.count++; } if(this.count===0){ this.x += this.speedX; this.y += this.speedY; } else{ this.x -= this.speedX; this.y -= this.speedY; }
initially count is supposed to be 1
Gunaraj Khatri
Learning web dev
Gunaraj KhatriNice one, Also You can add rect width to rect x position to get rect right side of the for bounce.
if(this.x + this.width === canvas.width)
Sudarshan Rai oh, yeah!!
Prajwal Pradhan
Waiting for more...
Shanti Moktan
Awesome and clear explaination.
Thank you Shanti Moktan
Challenge of bounce to-fro: modify in update() method
if(this.x===0){ this.count--; } if(this.x===canvas.width){ this.count++; } if(this.count===0){ this.x += this.speedX; this.y += this.speedY; } else{ this.x -= this.speedX; this.y -= this.speedY; }initially count is supposed to be 1