Member-only story

pong game with Javascript

YvonneDev
2 min readNov 2, 2020

--

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, a middle dashed line, a ball, and score display /

draw a 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

--

--

YvonneDev
YvonneDev

Written by YvonneDev

❤️Front-end Web Development self-taught *share what I learned*

No responses yet