pong game with Javascript
Features:
canvas rendering context,draw shape
win score with if(),then can start again
CODE Github
JAVASCRIPT
reset all the variables
and the ball in the center
Then createCanvasWith the blank canvas, render stuff on itThe canvas should be with two paddles,middle dashed line,a ball and score display /draw shape with canvas onMDN
the middle dashed line build with canvas setLineDash()
begin to animate()-->ball move and calculate the boundaries,then stop the game.
repeat animations smoothly with requestAnimationFrame() css tricks and requestAnimationFrame() MDN
the axis of ball changes based on speedIf ball hit the wall,the speed reduce.
If the ball hit the paddle,speed add. and calculate the score