pong game with Javascript

 

Features:

canvas rendering context,draw shape

win score with if(),then can start again

CODE Github 

DEMO

JAVASCRIPT


reset all the variables

and the ball in the center

Then createCanvas

With the blank canvas, render stuff on it

The 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 speed


If ball hit the wall,the speed reduce.

If the ball hit the paddle,speed add. and calculate the score

If player move,then computer move.

If the score reach the winScore, the first reached win.And show the winner

create the new overcome canvas. And can start game again with button click.

Popular posts from this blog

Fancyapps — easily build overlay windows with carousel

Thoughts about Progressive Web App

Meet Mantine: A TS-Based Open-Source React Components Library