Create Ping Pong Game Using JavaScript and HTML5 | JavaScript Project For Beginners

  Рет қаралды 142,791

Code Explained

Code Explained

Күн бұрын

Table tennis, also known as ping pong, is a game in which two or four players hit a little, light ball back and forth across a table using a small paddle. A point is scored when a player fails to return the ball to the other player. Basically, you’re playing tiny tennis on a table.
Today you're going to create the PING PONG game using JavaScript and HTML (or HTML5).
I will go step by step, and try to break down every line of code so everyone can understand the logic behind the game, after watching this tutorial, you will be able for sure to create the game on your own.
If you want to follow along with me when I type in the code, you'll need to download the starter template from GitHub.
-----------------------------------------------------------------------------------------------------
| LINKS |
-----------------------------------------------------------------------------------------------------
DOWNLOAD SOURCE CODE + STARTER TEMPLATE:
www.codeexplain...
🌍 Social Media Links.
◾ Facebook : / code.explained.official
◾ Twitter : / code_explained
◾ Instagram : / code.explained.official
◾ GitHub : github.com/Cod...
💲 Suppport the Channel
Paypal : paypal.me/Code...
Buy Me a Coffee: www.buymeacoff...
-----------------------------------------------------------------------------------------------------
| HASH TAGS |
-----------------------------------------------------------------------------------------------------
#JavaScript #Html5Games #JavaScriptGames

Пікірлер: 263
@lennoxsherwin5706
@lennoxsherwin5706 4 жыл бұрын
This is one of the best tutorials that I have ever seen. The concepts were explained really clearly and I learnt so much from this. Keep up the good work!
@CodeExplained
@CodeExplained 3 жыл бұрын
Happy to hear that, thanks a lot 💖
@cryptoballer3453
@cryptoballer3453 4 жыл бұрын
The way you took the time to diagram the breakdown at the beginning and made it so LEGIBLE for us, was priceless. Best tutorial. Looking forward to watch more of your stuff! Thank U
@CodeExplained
@CodeExplained 3 жыл бұрын
Happy to hear that, thanks a lot 💖
@kvaibz1147
@kvaibz1147 4 жыл бұрын
Your account is sooo underrated !!! This is the best js acc I've seen so farr
@Maxtasy888
@Maxtasy888 6 жыл бұрын
Very nice! I really liked that you explained the logic in the beginning. It made it so much easier to follow the coding later on. Great turorial!
@CodeExplained
@CodeExplained 6 жыл бұрын
thank you Maxtasy for your positive comment.
@CodeExplained
@CodeExplained 3 жыл бұрын
🚨 Big Announcement! 🚨 Hey everyone! I've made a big decision for this channel-I've turned off ads on all my videos! That's right, you can now enjoy all my content ad-free! This means I'm earning $0 from ad revenue, but I believe this is the right move to make your viewing experience better. If you find my content valuable and want to support my work, there are several ways you can help: Like & Share: Simply liking the video and sharing it with friends helps a lot! Subscribe & Hit the Bell: Stay updated and never miss a new video. KZbin Thanks: Use the "Thanks" button below to send a one-time donation. Join the Channel Community: Get exclusive perks and behind-the-scenes content. Buy Me a Coffee: buymeacoffee.com/CodeExplained PayPal Donation: www.paypal.com/paypalme/CodeExplained Every little bit counts and goes directly to creating more high-quality content for you all. Thank you so much for your continued support! Let’s keep growing and learning together! 🌟
@solomon_3748
@solomon_3748 2 жыл бұрын
You are the best coding teacher i have ever seen. The concepts,the reason n the logic behind each move and step...you explained it fully ... I really loved it. N I learned alot from your video. Never stop teaching us. Earth needs teachers like you! ✌️
@CodeExplained
@CodeExplained 2 жыл бұрын
Thanks a lot for your comment 🙏
@徐宏杰-i6w
@徐宏杰-i6w 5 жыл бұрын
best tutorial in KZbin,you explain every detail clearly.really hope you can create a series of JavaScript tutorial
@CodeExplained
@CodeExplained 4 жыл бұрын
Thank you, I will
@twosongs7396
@twosongs7396 2 жыл бұрын
I looooove the way you teach. Thank you so much for your tutorials. You’re a natural Teacher.
@shaf5169
@shaf5169 4 жыл бұрын
I have a semester-end assignment that requires me to make a website using only HTML CSS and javascript, but I don't like web development at all, I find it really boring because front-end is full of debugging and trying things until it looks right, on the other hand, I can call myself not a beginner in term of game development using game engines, so this is really fun to do for my assignment, thank you.
@CodeExplained
@CodeExplained 3 жыл бұрын
Happy to hear that, thanks 💖
@rubenhappy100
@rubenhappy100 5 жыл бұрын
This is the best tutorial video of canvas that I see on youtube. Great job!
@徐宏杰-i6w
@徐宏杰-i6w 5 жыл бұрын
Ruben Montanez i agree
@CodeExplained
@CodeExplained 4 жыл бұрын
Happy to hear that, Thanks!
@patrickmcauliffe7162
@patrickmcauliffe7162 4 жыл бұрын
GREAT tutorial and your explanation of the logic at the start is second to none! Watch 1.75xspeed and it is even better.
@CodeExplained
@CodeExplained 3 жыл бұрын
I'm so glad to hear this from you, thanks a lot 💖
@karlee8608
@karlee8608 6 жыл бұрын
Thank you so much for the detail explanation. I have learned a lot. I really appreciate. I am hoping you would do more games please.:)
@Billy_98
@Billy_98 4 жыл бұрын
holy...This is the best tutorial i ever saw in my life. I wonder how much time u spend on this clip.Big,big like!
@CodeExplained
@CodeExplained 3 жыл бұрын
I'm so glad to hear this from you, thanks a lot 💖
@twosongs7396
@twosongs7396 2 жыл бұрын
Ha! That’s nothing! Check out his Tetris Game tutorial! This guy’s a natural Teacher!
@deepresearchersbynk
@deepresearchersbynk 5 жыл бұрын
LOTS OF LOVE FROM PAKISTANI..............I REALLY LEARN TOO MUCH
@CodeExplained
@CodeExplained 5 жыл бұрын
Happy to hear that. a big Hi to Pakistan.
@deepresearchersbynk
@deepresearchersbynk 5 жыл бұрын
@@CodeExplained thanks sir
@johnatteo822
@johnatteo822 3 жыл бұрын
Great tutorial awesome job explaining it in the beginning. Only issue I see 👀 is when the player or computer scores the ball don't reset right away. It's like a 3 second delay before the speed resets. Other than that great work 🍻 👏
@thehommeyosh8605
@thehommeyosh8605 5 жыл бұрын
I am doing my final project for school and I chose "PONG" I viewed a ton of videos and |I would have to say I enjoyed how you broke it down before you open the editor I learned a lot and yes I did subscribed.
@CodeExplained
@CodeExplained 4 жыл бұрын
Happy to hear that, Thanks!
@federicofranciosi7180
@federicofranciosi7180 5 жыл бұрын
You are amazing !!! You shold be at university. You explain things in such a way that you CAN'T not understand. THANK YOU SO MUCH !!!!
@CodeExplained
@CodeExplained 5 жыл бұрын
You are welcome. and thank you aswell.
@sophia8443
@sophia8443 2 жыл бұрын
Your tutorial must be one of the best I have ever seen on KZbin! Just curious which tools do you use to make your videos? I always want to do something similar but found it quite difficult to make illustrations..
@microwavecoffee
@microwavecoffee 4 жыл бұрын
i seriously thought it was gonna be easy. great tutorial tho.
@khansawidhani9899
@khansawidhani9899 3 жыл бұрын
This is woww, what a tutorial. And you are the best explainer ever I have seen for this ping pong game.
@CodeExplained
@CodeExplained 3 жыл бұрын
Thanks, happy to help.
@АнтиподсосНокитокадзе
@АнтиподсосНокитокадзе 6 жыл бұрын
Liked before watching!
@CodeExplained
@CodeExplained 6 жыл бұрын
Thanks a lot.
@yofi2614
@yofi2614 2 жыл бұрын
Great tutorial! subbedd! BTW in 22:09 isnt the ball.bottom should be lower than the player.top? cause only if the ball bottom is lower than the player top there is gonna be a collision
@kazmon99
@kazmon99 5 жыл бұрын
10/10 great video, I learned alot
@CodeExplained
@CodeExplained 5 жыл бұрын
That's great
@antarikshhandique2951
@antarikshhandique2951 4 жыл бұрын
I like the way you explain all the things. Thx anf keep it up
@cynthiamanor6565
@cynthiamanor6565 5 жыл бұрын
You did an AWESOME job of explaining the logic behind your code!
@CodeExplained
@CodeExplained 4 жыл бұрын
Thank you
@CodingJourney
@CodingJourney 6 жыл бұрын
Quality content! Thanks!!!
@CodeExplained
@CodeExplained 6 жыл бұрын
You're welcome
@andersoncdz1
@andersoncdz1 Жыл бұрын
Thanks for sharing this masterpiece!!!!
@krishnavarma7395
@krishnavarma7395 4 жыл бұрын
Please keep continuing your great work man! Learned a lot from your videos as a beginner. :D
@CodeExplained
@CodeExplained 4 жыл бұрын
Happy to hear that. Thanks
@fabian8638
@fabian8638 2 жыл бұрын
Very well explained, even for a layman
@trueblue2714
@trueblue2714 5 жыл бұрын
If you want a solid line change these: width: 5, height: 20,
@coke1011
@coke1011 6 жыл бұрын
Please do more. I've watched your tetris in JavaScript it was extremely helpful. thanks a lot
@CodeExplained
@CodeExplained 6 жыл бұрын
You're welcome, and sure more tutorials are coming in the way :)
@zorozoro4055
@zorozoro4055 Жыл бұрын
thank u so much, u are the best, keep going
@revengerszone1206
@revengerszone1206 4 жыл бұрын
I completely understood due to his good explanation.
@CodeExplained
@CodeExplained 3 жыл бұрын
Happy to hear that, thanks 💖
@kedarsatwik6938
@kedarsatwik6938 3 жыл бұрын
superb explanation
@yukselbey913
@yukselbey913 6 жыл бұрын
Thank you so much for all your quality work. You are explaining very well.
@CodeExplained
@CodeExplained 6 жыл бұрын
You're welcome yuksel :) Thanks for your support.
@calvinmondele7395
@calvinmondele7395 6 жыл бұрын
Thanks for your help. mine worked nicely
@priyankabagoriya8483
@priyankabagoriya8483 4 жыл бұрын
Excellent Explanation I Really Enjoyed it For doing this. Much more comes
@CodeExplained
@CodeExplained 3 жыл бұрын
I'm so glad to hear this from you, thanks a lot 💖
@Ayoubased
@Ayoubased 2 жыл бұрын
Very good explanation. I just some couple questions. I still don't understand how the colision logic was made. you made 4 expressions in the if statement that return if collision is true or not. what do they represent? in your visuals. you showed 4 different ball positions, how can they all happen in the same time? My second question is what happens when the ball touches the bottom or the top of the paddle? shouldn't it bounce up/down and keep going same X direction?
@jamestangeres4875
@jamestangeres4875 5 жыл бұрын
You're awesome sir. Thank you for educating us with your well explained JavaScript game tutorials. God bless!
@CodeExplained
@CodeExplained 5 жыл бұрын
Thank you
@wandersongomes6733
@wandersongomes6733 4 жыл бұрын
Voce tem uma didatica incrivel. Nao tenho palavras pra descrever minha gratidao por voce ta compartilhando esse conteudo maravilhoso. Tenha certeza que voce faz a diferenca na vida de muitos. Obrigado e que Deus te abencoe e um abraco aqui do Brasil.
@CodeExplained
@CodeExplained 3 жыл бұрын
Happy to hear that, thanks 💖
@joeblow8394
@joeblow8394 5 жыл бұрын
This is an extremely thorough explanation and tutorial, so thanks for that. I do see two issues though. First is that the ball upon being reset is not properly reset to its starting speed (though logging out its speed shows it has been reset, i dont know whats happening here!), and second is that if the ball is going fast enough there seems to be collision detecting issues where the ball will phase right through the paddle?
@CodeExplained
@CodeExplained 5 жыл бұрын
Yeah that's some of the bugs you will ecounter.
@Martin958
@Martin958 2 жыл бұрын
Try changing the framePerSecond value @15:23 to update the game more times than 50 times a second. Not sure what would cause the reset value to be wrong if it shows zero.
@xiaoliuyu2033
@xiaoliuyu2033 9 ай бұрын
you are so good!!
@gouravchouhan1790
@gouravchouhan1790 4 жыл бұрын
Dude, I just ❤️❤️❤️ u, You're the one I was seriously looking for. ❤️❤️❤️❤️❤️❤️❤️You 😂
@CodeExplained
@CodeExplained 3 жыл бұрын
Happy to hear that, thanks 💖
@renderjourney
@renderjourney 5 жыл бұрын
Thanks for sharing this code 😇 But I‘m confused of your pronunciation of „width“. You pronounced it like „withid“ the whole time.😅
@ErrorDebug
@ErrorDebug 5 жыл бұрын
Yeah for me it sounds like "with it" xD
@CodeExplained
@CodeExplained 5 жыл бұрын
Yeah sorry. I didn't even realise that until people told me that.
@cryptoballer3453
@cryptoballer3453 4 жыл бұрын
@@ErrorDebug so what??? This guy has one of the best pong tutorials and you are finding problems with his pronunciation? For real dude!
@cryptoballer3453
@cryptoballer3453 4 жыл бұрын
@@CodeExplained man your accent is fine! I understood you CLEARLY!!!!
@codeTonight
@codeTonight 3 жыл бұрын
Great Video After 54:55, I think that there is still some angle problem present. Because the ball seems to reflect at angles other than 0,45,-45. Or maybe I am wrong? Thanks
@CodeExplained
@CodeExplained 3 жыл бұрын
So what is the solution you suggest?
@codeTonight
@codeTonight 3 жыл бұрын
@@CodeExplainedconsole log the value of collide point after normalizing it. I think that it would be other than -1,1,0. Use paranthesis in normalization line too
@nahidemdad5887
@nahidemdad5887 4 жыл бұрын
Very Good. We Want More and More.
@CodeExplained
@CodeExplained 3 жыл бұрын
I'm so glad to hear that from you, thanks a lot 💖
@Relachi
@Relachi 4 жыл бұрын
hi is it possible to substitute the ball with an image instead? What code can I use? I wrote this in JS: const ball = { x : canvas.width/2, y : canvas.height/2, radius : 10, speed : 5, velocityX : 5, velocityY : 5, speed : 7, } const ball = new Image(); img.src = "img/trump.png"; the game wont start anymore tho
@kushagra4586
@kushagra4586 4 жыл бұрын
Relachi bro u can’t use constant to assign 2 values to the same variable try using var instead
@kushagra4586
@kushagra4586 4 жыл бұрын
I mean u can’t use const
@orangegaming9562
@orangegaming9562 4 жыл бұрын
You need to use let/var instead of const The ball can’t be called twice Add image to one of the ball’s variables
@cryptoballer3453
@cryptoballer3453 4 жыл бұрын
I was thinking of putting a logo in the middle of the floor/net like they do on a basketball court. I will try!
@zababy
@zababy 4 жыл бұрын
@@cryptoballer3453 use [let ball {code here}] instead of [const ball {}]
@LLLearning1
@LLLearning1 4 жыл бұрын
Hi Thank you for your video, it is very detailed. I just have one question about the program. Which line starts it. I get the objects and functions to a degree, but the code that starts the programming running is what is stumping me.
@CodeExplained
@CodeExplained 4 жыл бұрын
JavaScript code in a page will be executed immediately while the page loads into the browser.
@athertonsecretary4385
@athertonsecretary4385 4 жыл бұрын
Enjoyed the project and got it running eventually! However, I can't stop it!!! What is the code for ending the game when a certain score is reached - say 10 by either player?
@souptiknath4668
@souptiknath4668 4 жыл бұрын
Best tutorial ever.Just love it!! But one question Why in ball.velocityX we have to multiply an angle?
@deathnotehindidubbed1375
@deathnotehindidubbed1375 4 жыл бұрын
Best explaination,but why didn't we use requestAnimationFrams? Like in the flappy bird?
@CodeExplained
@CodeExplained 4 жыл бұрын
There was no reason I guess. requestAnimationFrame will render the next frame only when your browser is ready to do so. per example if you leave the tab where you're game is loaded. the game well be paused until you get back to that tab. but that's not the case with setInterval.
@malekarous1418
@malekarous1418 5 жыл бұрын
thanks for the video its really well explained
@samdonaghybell
@samdonaghybell 4 жыл бұрын
Works great thank you. Has there been a fix for the ball going through the paddle at higher speed?
@samdonaghybell
@samdonaghybell 4 жыл бұрын
I actually worked around this by moving both paddles away from the left and right walls by 10px each.
@CodeExplained
@CodeExplained 3 жыл бұрын
I think I fixed the issue, by altering the position of the ball when there is a collision.
@masterdatta5361
@masterdatta5361 4 жыл бұрын
Nice tutorial! It sounds cool!
@CodeExplained
@CodeExplained 3 жыл бұрын
Glad you think so!
@williamwalker4494
@williamwalker4494 4 жыл бұрын
Thanks so much. Would be good with a 'Start Game' button, or restart button and great with a first to 10 points, then 'Gave Over'. Possible to add the code? I can do the HTML but get lost in the JS....
@CodeExplained
@CodeExplained 4 жыл бұрын
Yeah of course it's possible.
@Dawnclause
@Dawnclause 5 жыл бұрын
Best tutorials;)
@CodeExplained
@CodeExplained 5 жыл бұрын
Thanks
@lakshaysharmasharma5754
@lakshaysharmasharma5754 3 жыл бұрын
sir which softwer shall i use for making this game pls tell me
@collisioN_
@collisioN_ 4 жыл бұрын
very good video! thank you so much bro
@CodeExplained
@CodeExplained 4 жыл бұрын
Happy to hear that, Thanks!
@markthepianist6577
@markthepianist6577 4 жыл бұрын
Hello! Nice tutorial. But I had a little issue: When the ball hits user or com paddle it decreases its speed.
@brainreapers5241
@brainreapers5241 4 жыл бұрын
Sir I've got a question a beginner question, When i tried to run the program nothing pop up and i check the console and said Syntax error: Unexpected identifier. Edit: I need yo know how to fix it.
@shivanshattri2530
@shivanshattri2530 4 жыл бұрын
This Is Not A Beginner Question, You Are Not Even A Beginner!
@Smitxt
@Smitxt 4 жыл бұрын
so i have a weird problem in which that the ball doesnt reset upon hitting the edges of the screen unless the paddle touches it i changed the value in the "update score" segment and anything above 10 requires that the paddle be in front for the computer to score same problem for the computer paddle how do i fix this?
@Smitxt
@Smitxt 4 жыл бұрын
nevermind i found out that you had to put the resetBall function placement above other functions
@amindhahri2542
@amindhahri2542 3 жыл бұрын
What should I do if the ball draw a line instead of stay a circle?
@CodeExplained
@CodeExplained 3 жыл бұрын
I think you need to clear the canvas. ctx.clearRect(0, 0, canvas.width, canvas.height);
@amindhahri2542
@amindhahri2542 3 жыл бұрын
@@CodeExplained ah ok nice thanks I will try
@amindhahri2542
@amindhahri2542 3 жыл бұрын
@@CodeExplained I fixed it but thanks for help
@CodeExplained
@CodeExplained 3 жыл бұрын
great
@danielthapamagar2179
@danielthapamagar2179 5 жыл бұрын
what a explain MAN!!! thanks !
@CodeExplained
@CodeExplained 4 жыл бұрын
You're welcome
@wandersongomes8405
@wandersongomes8405 4 жыл бұрын
Eu amo seu canal.
@CodeExplained
@CodeExplained 3 жыл бұрын
Thanks a lot 👍
@muzamal9881
@muzamal9881 4 жыл бұрын
Hi, could you use an endgame function in this to give users a score? If yes, how so. Thanks
@CodeExplained
@CodeExplained 3 жыл бұрын
Did you figure out how to do it?
@zanhaahanz7628
@zanhaahanz7628 5 жыл бұрын
Perfect explanation
@CodeExplained
@CodeExplained 4 жыл бұрын
Glad you enjoyed it!
@cryptoballer3453
@cryptoballer3453 4 жыл бұрын
I am new to Javascript so my challenge will be to add a game over at 21 points (like an old-school ping pong game).
@CodeExplained
@CodeExplained 3 жыл бұрын
Yeah cool
@davidhernandez1699
@davidhernandez1699 5 жыл бұрын
Got a glitch where the ball gets stuck in the paddle or sometimes along the bottom width of the board. Any hints? Excellent video, btw.
@tommyplays5436
@tommyplays5436 4 жыл бұрын
review collision tunneling.
@somebody-17546
@somebody-17546 3 жыл бұрын
return p.left < b.right && p.top < b.bottom && p.right > b.left && p.bottom > b.top; 49:30 I can't understand .Can you explain it . What value it will return
@CodeExplained
@CodeExplained 3 жыл бұрын
It will return either TRUE or FALSE.
@pweissge
@pweissge 4 жыл бұрын
I have a problem in my thinking logic if there is a collision one of the 4 cases can happen but not all the 4 at the same time why do we use AND in the if clause and not OR. Thank you.
@CodeExplained
@CodeExplained 3 жыл бұрын
There won't be a collision if all the conditions weren't all true.
@amatakchannel3735
@amatakchannel3735 3 жыл бұрын
amazing!
@wandersongomes8405
@wandersongomes8405 4 жыл бұрын
Muito obrigado. Voce me ajudou bastante.
@CodeExplained
@CodeExplained 3 жыл бұрын
Happy to hear that, thanks 💖
@ahsanazeem4079
@ahsanazeem4079 4 жыл бұрын
I wanted to make a two player ping pong but I cant detect the key presses if one player just spams the key the second press is not issued. Help me
@CodeExplained
@CodeExplained 3 жыл бұрын
READ this: stackoverflow.com/questions/5203407/how-to-detect-if-multiple-keys-are-pressed-at-once-using-javascript
@TheBobstar89
@TheBobstar89 5 жыл бұрын
Love the video, however I am curious how you decided to divide the width by 1/4ths and height by 1/5ths
@CodeExplained
@CodeExplained 4 жыл бұрын
It depends on the width and the height I guess. if per example the width was = 5px, dividing by 5 will be better than dividing by 4.
@trangnguyenthibaotrang6944
@trangnguyenthibaotrang6944 4 жыл бұрын
Thank you so much
@CodeExplained
@CodeExplained 3 жыл бұрын
You're most welcome
@javaexpertsa8947
@javaexpertsa8947 6 жыл бұрын
Awesome content!!!
@CodeExplained
@CodeExplained 6 жыл бұрын
Thank you.
@Ayoubased
@Ayoubased 2 жыл бұрын
I still cant understand the collison between the ball and player? I wish I can get a 1 on 1 explanation to see where I missed my logic
@aravind_k28
@aravind_k28 4 жыл бұрын
Awesome :)
@angel-k5j5j
@angel-k5j5j 3 жыл бұрын
How can I put a another mid line as an obstacle?:0 I mean, a little middle solid line as a little wall
@CodeExplained
@CodeExplained 3 жыл бұрын
YOu can simply draw a rectangle, but then you'll need to add some collision detection for it to work
@leogansallo-sadiq2864
@leogansallo-sadiq2864 5 жыл бұрын
Hi, love your work. But I've a problem @46:10. In my code i believe I've all the code correctly written but it wont show me my output canvas instead a blank page. What can i do to fix this problem. Thanks. Great work again.
@CodeExplained
@CodeExplained 5 жыл бұрын
Show me your code, or open the console and try to debug your code.
@leogansallo-sadiq2864
@leogansallo-sadiq2864 5 жыл бұрын
@@CodeExplained please how can i show you my code. I don't mind showing you my code. Thanks
@CodeExplained
@CodeExplained 5 жыл бұрын
paste here.
@leogansallo-sadiq2864
@leogansallo-sadiq2864 5 жыл бұрын
@@CodeExplained //select canvas const cvs = document.getElementById("pong"); const ctx = cvs.getContext("2d"); //create the user paddle (object) const user = { x : 0, y : cvs.height/2 - 100/2, width : 10, height : 100, color : "white", score = 0 } //create the computer paddle (object) const com = { x : cvs.width - 10, y : cvs.height/2 - 100/2, width : 10, height : 100, color : "white", score = 0 } //create the ball (object) const ball = { x : cvs.width/2, y : cvs.height/2, radius : 10, speed : 5, velocityX : 5, velocityY : 5, color : "white" } //draw rect function function drawRect(x, y, w, h, color){ ctx.fillStyle = color; ctx.fillRect(x, y, w, h); } //create the net (object) const net = { x : cvs.width/2 -1, y : 0, width : 2, height : 10, color : "white" } //draw net function drawNet(){ for(let i = 0; i
@CodeExplained
@CodeExplained 5 жыл бұрын
In your com and user objects you used an equal sign for the score property.
@epixtille7069
@epixtille7069 4 жыл бұрын
Is there any way we can create a menu screen to allow the user to select the difficulty
@CodeExplained
@CodeExplained 3 жыл бұрын
Yeah of course.
@lavisworld5142
@lavisworld5142 5 жыл бұрын
Subscribed😃😃😃😄
@devashanpillay1737
@devashanpillay1737 5 жыл бұрын
after a while th com paddle disappears and the score keep incrementing. Any idea why?
@CodeExplained
@CodeExplained 5 жыл бұрын
can't tell if I don't see what's in the console log.
@themagicaltv954
@themagicaltv954 4 жыл бұрын
can you pls tell that you make this game by which website
@CodeExplained
@CodeExplained 3 жыл бұрын
brackets.io
@mariuswiborg8146
@mariuswiborg8146 5 жыл бұрын
How do you make the basic html template??
@CodeExplained
@CodeExplained 5 жыл бұрын
What ?
@CodeExplained
@CodeExplained 5 жыл бұрын
I'm using an extension called EMMET with brackets editor, it completes the code for you, per example I just need to type: " ! + TAB " to create the basic HTML code. and thanks.
@mariuswiborg8146
@mariuswiborg8146 5 жыл бұрын
Code Explained ok thank you very much for the fast answer. Love your work
@matto2041
@matto2041 4 жыл бұрын
thanx i really like your teaching style and that you take ur time! :subs:
@CodeExplained
@CodeExplained 3 жыл бұрын
Happy to hear that, thanks 💖
@AndrewErwin73
@AndrewErwin73 4 жыл бұрын
Why not use RequestAnimationFrame?
@Aayush-cd3dc
@Aayush-cd3dc 4 жыл бұрын
In which software you have made
@CodeExplained
@CodeExplained 3 жыл бұрын
brackets.io
@genttner
@genttner 4 жыл бұрын
cvs.getContext("2d"); {RETURNS BACK: script.js:2 Uncaught TypeError: Cannot read property 'getContext' of null at script.js:2}
@genttner
@genttner 4 жыл бұрын
stupid errors like these are swift kicks in the nuts
@CodeExplained
@CodeExplained 3 жыл бұрын
Did you fix it? I think there is a problem with cvs, you didn't select right the canvas.
@ARMADA-oz6we
@ARMADA-oz6we 5 жыл бұрын
you know a tutorial is amazing if it becomes unclear within the first 2 minutes of the 55
@CodeExplained
@CodeExplained 4 жыл бұрын
Happy to hear that. Thanks!
@ARMADA-oz6we
@ARMADA-oz6we 4 жыл бұрын
@@CodeExplained wasn't a compliment, but if it makes you feel better feel free to think of it as one
@shubhampanchal7098
@shubhampanchal7098 5 жыл бұрын
The Ball is not moving ,nor the com paddle , where can the error possibly be ??
@CodeExplained
@CodeExplained 5 жыл бұрын
Take a look on your console log. or show me your code.
@theamoralfish530
@theamoralfish530 5 жыл бұрын
*Thanks You!*
@CodeExplained
@CodeExplained 5 жыл бұрын
You're welcome
@4rtui1
@4rtui1 4 жыл бұрын
does this work on notepad?
@CodeExplained
@CodeExplained 3 жыл бұрын
??
@4rtui1
@4rtui1 3 жыл бұрын
@@CodeExplained You know, some people use notepad for making websites and sometimes games
@CodeExplained
@CodeExplained 3 жыл бұрын
Yeah you can make the same thing with any text editor out there.
@gsharma8781
@gsharma8781 5 жыл бұрын
amazing, bro
@CodeExplained
@CodeExplained 5 жыл бұрын
Thanks
@dearsb69
@dearsb69 4 жыл бұрын
I'm a beginner Sir and I cannot find a software on which I can write and edit my code please help me Sir and lots of love from India
@CodeExplained
@CodeExplained 4 жыл бұрын
In this video I used brackets.io
@Ellen_Yuri
@Ellen_Yuri 5 жыл бұрын
thank you !!!
@CodeExplained
@CodeExplained 4 жыл бұрын
You're welcome!
@vellacreator
@vellacreator Жыл бұрын
please decrease the frequency of the sound it as it hurts when we use earphones
@pedroalbuquerque4519
@pedroalbuquerque4519 5 жыл бұрын
how do I make the user move with the keyboard instead of the mouse?
@CodeExplained
@CodeExplained 5 жыл бұрын
Use onkeydown event listener.
@lefoudupinpon
@lefoudupinpon 5 жыл бұрын
Have you understood how to use the onkeydown event listener ? If the answer is yes please let me know how you fixed it.
@studywithlakshsurana
@studywithlakshsurana 4 жыл бұрын
how can we add a limit that after this point the game will get over
@CodeExplained
@CodeExplained 3 жыл бұрын
Did you figure out how to do it?
@MinhLe-sl5vm
@MinhLe-sl5vm 4 жыл бұрын
I am figuring out a way to implement a gameover function to end the game if either player or computer reaches 10 score. Can anyone give me a hint on how to do it?
@CodeExplained
@CodeExplained 3 жыл бұрын
Did you figure out how to do it, or still need help?
@MinhLe-sl5vm
@MinhLe-sl5vm 3 жыл бұрын
@@CodeExplained I have figured it out. Thank you so much!
@MinhLe-sl5vm
@MinhLe-sl5vm 3 жыл бұрын
@@CodeExplained I have figured it out. Thank you so much!
@CodeExplained
@CodeExplained 3 жыл бұрын
Great
The Easiest Javascript Game Ever
8:34
KnifeCircus
Рет қаралды 979 М.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
Beginner JavaScript Project - Snake Game Tutorial
1:38:19
freeCodeCamp.org
Рет қаралды 102 М.
HTML Canvas DEEP DIVE
49:43
Franks laboratory
Рет қаралды 112 М.
A game of Pong written in JavaScript 🏓
24:48
Bro Code
Рет қаралды 77 М.
Every Programming Language Ever Explained in 15 Minutes
15:29
Flash Bytes
Рет қаралды 372 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 584 М.
Coding Adventure: Boids
8:35
Sebastian Lague
Рет қаралды 1,6 МЛН
How To PLAN your Game as a Solo Developer
16:26
Heartbeast
Рет қаралды 543 М.
Пишем игру " Пинг понг " на JavaScript
19:39
Making a Game With C++ and SDL2
8:14
PolyMars
Рет қаралды 1,7 МЛН