Тёмный

Create Flappy Bird clone in Javascript HTML CSS 

Kenny Yip Coding
Подписаться 23 тыс.
Просмотров 56 тыс.
50% 1

How to code flappy bird in javascript, html, and css.
In this tutorial, you will learn to create the flappy bird game with html, css, and javascript. Specifically, you will learn how to code the game using html5 canvas.
Throughout the tutorial, you will learn how to create the game loop, add images onto the canvas, add click handlers to make the flappy bird jump, randomly generate pipes and move them across the screen, detect collisions between the flappy bird and each pipe, and add a running score.
Code: github.com/ImKennyYip/flappy-...
Demo: imkennyyip.github.io/flappy-b...
Website: www.kennyyipcoding.com/
Java Game Programming Projects Playlist:
• Java Game Programming ...
JavaScript Game Programming Projects Playlist:
• JavaScript Game Progra...
Subscribe for more coding tutorials 😄!

Опубликовано:

 

18 фев 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 88   
@PinguinAutiste
@PinguinAutiste 11 месяцев назад
quick tip, In vs code in html just type ! then hit tab and you will have the entire code
@azureharris8647
@azureharris8647 10 месяцев назад
I love your channel. You are the only youtuber that really goes into debt and explains everything. Perfectly
@masterman7624
@masterman7624 Год назад
Your vids are amazing bro, as a beginner, they are helping me massively keep it up
@RayShine52777
@RayShine52777 Год назад
Your video is so useful and easy-understanding. I love it! Thank you for teaching me this and improving my Javascript
@hapikus5157
@hapikus5157 Год назад
Waited 1,5 months! Thanks a lot!
@henkdevries6380
@henkdevries6380 3 месяца назад
really helpfull when you draw out what you are programming, helped me alot. Good tutorial video.
@chetanrathi8070
@chetanrathi8070 8 месяцев назад
awsome tutorial!!! you make coding game look like playing it!
@chetanrathi8070
@chetanrathi8070 8 месяцев назад
super awesome!!! just finished it!!
@Hoodies
@Hoodies Год назад
This tutorial is very helpfull, and well explained. I just think that u should add the code for resetting the bird as his original place when u restart the game cause the bird will spawn as the exact same place he died in the precedent run. Anyway thank you a lot it was a very nice tutorial.
@KennyYipCoding
@KennyYipCoding Год назад
Check out the playlist of web project tutorials here! ru-vid.com/group/PLnKe36F30Y4bLhA-st9sC4ZthyV7nsL2Q Got a tutorial suggestion? Let me know down below!
@Umut34
@Umut34 11 месяцев назад
Thank you my friend amazing tutorial
@zarakikenpachi1773
@zarakikenpachi1773 Год назад
I have a really small request, hoping you could incorporate it in one/some of your tutorials. If you could show how to add a clickable link or modal to a canvas game, and how to make the game responsive for standard phone and tablet screen sizes. Apart from that, amazing tutorial. Thanks a lot for your efforts.
@Shubham-vh3cp
@Shubham-vh3cp 8 месяцев назад
Thanks a lot bro you are just awesome🥰
@Eminence-in-shadow
@Eminence-in-shadow Год назад
This has helped me soo much
@anishmainali6535
@anishmainali6535 Год назад
you are too good love from nepal
@chrisrutledge2348
@chrisrutledge2348 7 месяцев назад
Only recommendation would be to have touch support. Otherwise, this is awesome!
@nicholaskh5306
@nicholaskh5306 Год назад
keep it up bro
@johnanthonylontoc151
@johnanthonylontoc151 Год назад
Your video is so good!!but can you make a video of that flappy bird but with highscore theme
@artofbenjo3700
@artofbenjo3700 7 месяцев назад
how to center the text Game Over?
@blin5033
@blin5033 2 месяца назад
i cannot figure out why i cant get the imagine of flappybird to load it just stays a green block
@zoku5896
@zoku5896 2 месяца назад
thanks!
@ksamuelchris
@ksamuelchris 3 месяца назад
This is great example of creating flappy bird with HTML5 I would like to know if you would talk about making the game for mobile . For example using the screen to make the bird move by tapping the screen. I also was wondering about game sound input and perhaps level generations
@KennyYipCoding
@KennyYipCoding 3 месяца назад
Not sure what levels you would make with flappy bird since it’s an infinite platform game. Unfortunately web on mobile is different from mobile apps so there are limitations on what you can do. You could add a mouse click handler function (check my wordle or sudoku tutorial where I show how to create one) and add the code that makes the bird jump into the mouse click handler.
@Rafael_2008
@Rafael_2008 19 дней назад
i have a question about the birdImg.src, for the js in the newest version, the js couldn't read it, can you help me ASAP please?
@KennyYipCoding
@KennyYipCoding 19 дней назад
Right click inspect console, what error do you see? Also I have the completed code for you to compare. It could be your img path is not correct
@trying-code3726
@trying-code3726 Год назад
nice sir
@Error-er1ki
@Error-er1ki 26 дней назад
THANKYOU SO MUCH!!!!, I JUST DID YOUR CHALLENGE AND IT WORKING NOW. But my real challenge is giving it a coins to collect or pts to earn to acquire some power ups :< its so damn hard. Hope I can finish it.
@xzex2609
@xzex2609 2 месяца назад
Hi I have a problem with the setInterval() timing , if I pass 1500 there will be just one pipe in the game , but around 500-700 ms is ok but the game appear fast. shouldn't be these timing standard , why when I set it to 1.5 I have just one pipe? should i use setTimeOut function to make delay? what do I do with just one pipe?
@josearanda2558
@josearanda2558 26 дней назад
writing it in vs code and I completed the first 5 minutes of the tutorial, am I doing something wrong?
@user-ru3mg9jh6f
@user-ru3mg9jh6f 4 месяца назад
Awesome :D
@cotonillo
@cotonillo 7 месяцев назад
Nose inglés pero Justo lo que buscaba
@saddamdhaif8793
@saddamdhaif8793 3 месяца назад
I have problem with let board;
@yamraj4054
@yamraj4054 9 месяцев назад
can someone help me when i tried to run the Top pipe movement code, the pipes did sucessfully moved to left but then they left a black screen between them
@KennyYipCoding
@KennyYipCoding 9 месяцев назад
Not sure what this bug looks like but perhaps you could compare the completed code with the one you wrote and see if you missed something?
@ievgenod9708
@ievgenod9708 8 месяцев назад
Most probably you wrote birdHeight istead of boardHeight in clearRect function)
@RoadRageEntertainment
@RoadRageEntertainment 2 месяца назад
I've went a long and made sure all my code was lined to yours and everything was working fine at first but than i went to check again and it stays stuck on the bluescreen and doesnet update the dementions when i view live server in visuail studio and doesen't update the background and I double checked the code is right
@KennyYipCoding
@KennyYipCoding 2 месяца назад
did you link your css.js properly?
@RoadRageEntertainment
@RoadRageEntertainment 2 месяца назад
@@KennyYipCoding pretty sure I did doube check but now im trying to do the snake game and the html just does not want to read my javascript, your videos are awesome and helpful but when i try to open it i get the letters but it doesent update the picture
@randomplay9145
@randomplay9145 10 месяцев назад
God Bless You
@Maxi_Puch
@Maxi_Puch 8 месяцев назад
how do i run it on my browser
@anngela6345
@anngela6345 Месяц назад
How to add music?
@vitaminprotein2217
@vitaminprotein2217 2 месяца назад
the reset thing not working anyway gr8 tutorial :D
@user-qc7nc5tt3l
@user-qc7nc5tt3l Год назад
this was pretty awesome! but once you have made a game like this one, how would you upload it or publish it in an actual website? i've followed this tutorial but cant seem to figure it out how to publish it in a website. i've tried to test what i have so far but cant seem to be able to embed it. any help is greatly appreciated!!!
@KennyYipCoding
@KennyYipCoding Год назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OltY8JIaP-4.html I have a video showing how to upload a webpage for free on GitHub
@lovelypicturepro
@lovelypicturepro 26 дней назад
just put the same code on neocities
@Asifkhan-rv2bc
@Asifkhan-rv2bc 5 месяцев назад
bro i write the same code like you write but after adding pipes moving code, there is no gap between two pipes ,my game background is not visible can you tell what i should i do
@KennyYipCoding
@KennyYipCoding 5 месяцев назад
Right click inspect and see if there’s an error message. Best thing to do is to backtrack, rewatch the previous parts of the videos and try to catch where you made a mistake!
@vitaminprotein2217
@vitaminprotein2217 2 месяца назад
same issue lol
@syetoday2942
@syetoday2942 8 месяцев назад
how do i add the flappybird.css and flappybird.js?
@anakayam.45
@anakayam.45 3 месяца назад
On head tag you can add link tag and script tag
@PinguinAutiste
@PinguinAutiste 11 месяцев назад
and for the flappy bird instead of drawing it with complicated math, can't you just create a div called bird and in the CSS file put the flappy bird image in the div with: background-image: url(Birb); and then code it to move? and then do the same thing with the board cuz it looks complicated compared of what you did with the Whack a mole vid
@KennyYipCoding
@KennyYipCoding 11 месяцев назад
It may seem complicated but it actually isn’t once you take a bit of time to understand it. This is fundamental for game programming. The css trick is just a hacky way to do it and is not recommended.
@KennyYipCoding
@KennyYipCoding 11 месяцев назад
For games that only require clicking on a grid/board, it’s easier to create html elements. But a game involving movement and physics, you’re better off using canvas or some other graphics library.
@zoltanszadoczki5665
@zoltanszadoczki5665 8 месяцев назад
Hy! I have a problem and I dont know why... when I try to set the board sizes in the js file, it dont do nothin. I checked and i think i am wrote the same as you. I refered int the html correctly I tried with a alert message. I have the same issues with other games tutorials to. Please help me!:) My code: js let board; let boardWidth = 500; let boardHeight = 640; let context; let birdWidth = 34; let birdHeight = 24; let birdX = boardWidth/8; let birdY = boardHeight/2; let bird = { x : birdX, y : birdY, width : birdWidth, height : birdHeight } window.onload = function(){ board = document.getElementById("board"); boardHeight = boardHeight; boardWidth = boardWidth; context = board.getContext("2d"); } context.fillStyle = "green"; context.fillRect(bird.x, bird.y, bird.width, bird.height);
@KennyYipCoding
@KennyYipCoding 8 месяцев назад
Inside window.onload, it should be: board.height = boardHeight; board.width = boardWidth;
@zoltanszadoczki5665
@zoltanszadoczki5665 8 месяцев назад
Thank you now better but I still not have the bird
@zoltanszadoczki5665
@zoltanszadoczki5665 8 месяцев назад
And IT is jumps back , when I wrote what you suggest it worked but now thensame issue
@david-agarpowers3555
@david-agarpowers3555 3 дня назад
yo i did the same but if i press the key to make the bird jump it will go super fast that rlly weird
@KennyYipCoding
@KennyYipCoding 3 дня назад
I forgot to take into account the refresh rate (used by requestAnimationFrame), mine is 60hz yours might be faster. In this case it’d be better to use setInterval(update, 1000/60); so that it’s 60 frames per second
@david-agarpowers3555
@david-agarpowers3555 3 дня назад
@@KennyYipCoding yh i got 165hz, gotts try it tommorow
@CryptoGrady
@CryptoGrady 4 месяца назад
LFG!! 🔥🔥🔥
@omniaabdalaziz7917
@omniaabdalaziz7917 Месяц назад
can you please put the link of the pictures of the pic even the pipes pleeeeeease
@KennyYipCoding
@KennyYipCoding Месяц назад
As mentioned in the video, it’s in the GitHub link in the video description
@sahilprasad4417
@sahilprasad4417 9 месяцев назад
Why my code is not working
@dhruvbharti-yv2qs
@dhruvbharti-yv2qs 28 дней назад
Good work bro But your bird Wing is not moving
@CimorelliRules1000
@CimorelliRules1000 6 месяцев назад
I am stuck on how to add the mouse click into this :/ can someone help?
@KennyYipCoding
@KennyYipCoding 6 месяцев назад
You need to assign a mouse click event handler to the canvas tag. Check out my other tutorials like wordle or connect 4 to see how to do that!
@CimorelliRules1000
@CimorelliRules1000 6 месяцев назад
@@KennyYipCoding thank you! I have been stuck on this for over 10 mins. I appreciate the comment :)
@CimorelliRules1000
@CimorelliRules1000 6 месяцев назад
@@KennyYipCoding 1 more question. Where in the code would I add it?
@marcosek5103
@marcosek5103 6 месяцев назад
22:58
@57Gulbar
@57Gulbar 3 месяца назад
Hello, can you explain me how do u find the ratio like the 17 and 12, i know that u did x2 for 34, 24. But the 17 and 12 iam lost.... Btw i do like this video and your tutorial, nice job.
@KennyYipCoding
@KennyYipCoding 3 месяца назад
Width of image / height of image, is the ratio you wan my to scale
@ellis-pr7hh
@ellis-pr7hh 9 месяцев назад
the explanation is so great and code is pretty much easy to understand ..just one question ..as someone is playing the game, after some period of playing usually games gets pretty fast so that it becomes hard to play...can we do in this too? if yes then how..
@KennyYipCoding
@KennyYipCoding 9 месяцев назад
Yes you can build levels or check after a certain number of points, you can increase certain things like how fast the player is going. In the case with flappy bird, I don’t think anything changes . Check out my space invaders tutorial for an example!
@ellis-pr7hh
@ellis-pr7hh 9 месяцев назад
@@KennyYipCoding alrighty thank you
@omniaabdalaziz7917
@omniaabdalaziz7917 16 дней назад
please send us the link of the whole code pleeeeeeease
@KennyYipCoding
@KennyYipCoding 16 дней назад
It’s in the video description in the GitHub link…..
@omniaabdalaziz7917
@omniaabdalaziz7917 16 дней назад
send it here pls i am subscribed
@omniaabdalaziz7917
@omniaabdalaziz7917 16 дней назад
i am the biggest fan
@KennyYipCoding
@KennyYipCoding 16 дней назад
@@omniaabdalaziz7917 github.com/ImKennyYip/flappy-bird
@aasthapant
@aasthapant 3 месяца назад
hey i have recently started practicing your vids and i must say you are incredible!! Is there your community page on discord ,insta or anywhere else where we could post over frequent queries and get other's suggestions as well as yours along with project ideas?
@MrEgg_lol
@MrEgg_lol Месяц назад
Ignore this comment👍 9:28
@pandabloxplays2577
@pandabloxplays2577 Месяц назад
Bro you didnt make it mobile device friendly. Wtf
@KennyYipCoding
@KennyYipCoding Месяц назад
Well games are generally designed to be played on a computer/console or as mobile applications. People generally don’t go on mobile websites to play games.
@pandabloxplays2577
@pandabloxplays2577 Месяц назад
@@KennyYipCoding then why did you adjust it for mobile devices using meta name? That just seemed redundant if you weren't gonna actually make it mobile friendly?
@infinite2886
@infinite2886 5 месяцев назад
Bad game
@JosueSilva7
@JosueSilva7 5 месяцев назад
19:21
Далее
Code Doodle Jump in Javascript
51:40
Просмотров 18 тыс.
How to code snake game in JavaScript
29:45
Просмотров 104 тыс.
How to make 2048 Game with Javascript HTML CSS
37:49
Просмотров 45 тыс.
Beginner JavaScript Project - Snake Game Tutorial
1:38:19
How to create a CSS navigation bar in 6 minutes! 🧭
6:28
Code Flappy Bird in Java
54:02
Просмотров 19 тыс.
Slide Puzzle Game in JavaScript HTML CSS
25:38
Просмотров 34 тыс.