Code Flappy Bird in Java

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.พ. 2025
  • How to code flappy bird game in java. In this tutorial, you will learn how to code flappy bird using java awt/swing graphics.
    Throughout the tutorial, you will learn how to create the game loop, create a jframe and jpanel, draw images on the jpanel, 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.
    Setup Java with Visual Studio Code:
    • How to set up Java in ...
    Code: github.com/ImK...
    Website: www.kennyyipco...
    Java Game Programming Projects Playlist:
    • Java Game Programming ...
    JavaScript Game Programming Projects Playlist:
    • JavaScript Game Progra...
    Subscribe for more coding tutorials 😄!

ความคิดเห็น • 201

  • @SiddhantPardeshi-z8k
    @SiddhantPardeshi-z8k ปีที่แล้ว +20

    Thank you sir. Your Java videos are really Wonderful. They motivate me to learn java more deeply. I am a third year cs engineering student enjoying your videos. Completed the tutorial and it's working. You are a great teacher ❤️❤️😊

  • @Legendary_MoMo
    @Legendary_MoMo ปีที่แล้ว +16

    I have to say, your java videos have been very helpful for me, thank you very much mate

  • @kiro1923
    @kiro1923 9 หลายเดือนก่อน +55

    this past month my college faculty announced a strike, and i stopped studying java for these few weeks. But your videos made me code all week long and practice everyday! Your way to teach is very easy to understand, keep the great work! I think in a few I'll watch your web dev games and practice with them too!

    • @KennyYipCoding
      @KennyYipCoding  9 หลายเดือนก่อน +4

      ahh sorry to hear that! Fortunately youtube exists :) ! Glad you enjoy the tutorials! Will be uploading more as the year goes on.

  • @landon0000
    @landon0000 4 หลายเดือนก่อน +13

    Buddy is a champ, up at 3AM making tutorials

  • @CrackBack999
    @CrackBack999 8 หลายเดือนก่อน +7

    great tutorial man, your videos are the only ones i can follow without getting a thousand errors. I subbed

  • @alllatesttoday1387
    @alllatesttoday1387 10 หลายเดือนก่อน +277

    Bro I'm going to submit this as my final year java project
    . Wish me luck🤞🏾💪🏾
    Quick update!!!
    I completely changed your code, added sound effects and actually changed the whole game and named it "Flappy Chicken". Y'all could think what i did here 😂. I changed the theme of the game completely and turned it into a Minecraft chicken jumping over Minecraft trees game. Like wthhh💀 well at least i got full marks though❤

    • @tasneemahsan6849
      @tasneemahsan6849 10 หลายเดือนก่อน +5

      I’m working on this form my Java class’ final project as well

    • @3bood_kr
      @3bood_kr 10 หลายเดือนก่อน +4

      Final year of what

    • @_Prit_Patel_
      @_Prit_Patel_ 9 หลายเดือนก่อน

      ​@@3bood_kr His degree, probability BE BTech!!!

    • @hananch786
      @hananch786 8 หลายเดือนก่อน +1

      😂 brother I'm also submitting this project

    • @youarethecssformyhtml
      @youarethecssformyhtml 7 หลายเดือนก่อน +2

      I don't believe in luck

  • @demiantah3179
    @demiantah3179 หลายเดือนก่อน +1

    Amazing job, honestly I found very informative your videos and I´ll share your page with my friends!

  • @mayurhiware9336
    @mayurhiware9336 6 หลายเดือนก่อน +3

    Thank you so much for this wonderful Video , At every stage of making my first game from making own window to the final game is Journey where I got happiness at every stage of this wonderful Project ! 😊

  • @gogogaming1491
    @gogogaming1491 4 หลายเดือนก่อน

    i found this soo helpful to increase logic of java and made the first ever game thanku so much for explaining each concept clearly.

  • @ethanol-n6q
    @ethanol-n6q 19 วันที่ผ่านมา

    thanks for the awesome videos it has realy helped me learn java as a kid :)

  • @tungstun-o1d
    @tungstun-o1d 5 หลายเดือนก่อน +1

    dude u saved my life without knowing it thanks

  • @Subhasish3030
    @Subhasish3030 19 วันที่ผ่านมา

    very amazing for beginners ,, 👌👌👌

  • @eyzake
    @eyzake 9 หลายเดือนก่อน +2

    so far so good ... i used vim to write the code (was using vim for the first time ... i can say this much i am a fast learner... learnt some java swing , and how projects are made and ofcourse how to run terminal in vim and also i learnt i can compile multiple files using javac app.java flppybird.java anf then bla bla bla) man i still have to complete this video (rn i am where you explained, oh just as a quick recap the screen resolution is this and we got the bg image loaded) ama go grab something to eat i am tired
    edit just realised: it has only been 12 minutes (i wanna cry)

  • @williamkakooza4603
    @williamkakooza4603 10 หลายเดือนก่อน +1

    Thank you Professor Ken😊

  • @damirospanbek4339
    @damirospanbek4339 11 หลายเดือนก่อน +3

    so clean thank you for such a content

  • @Commentseeker-jg8us
    @Commentseeker-jg8us หลายเดือนก่อน +1

    Hello, I have a question. I don't know much about GUI coding and I picked this program to know about it better.
    At 23:51, The bird in your program is going upwards while in my program it is still. The loop is working still and I checked the move function seems to be same as yours. So I am not really getting the problem. I will paste the code down here.
    public class FlappyBird extends JPanel implements ActionListener{
    int boardwidth=360;
    int boardheight=640;
    Image bottomPipeImg;
    Image topPipeImg;
    Image flappybirdImg;
    Image backgroundImg;
    int birdX = boardwidth/8;
    int birdY = boardheight/2;
    int birdwidth = 34;
    int birdheight = 24;
    class Bird {
    int x = birdX;
    int y = birdY;
    int width = birdwidth;
    int height = birdheight;
    Image img;
    Bird(Image img) {
    this.img = img;
    }
    }

    Bird bird;
    int velocityY = -6;
    Timer gameloop;
    FlappyBird() {
    setPreferredSize(new Dimension(boardwidth, boardheight));
    setBackground(Color.blue);
    backgroundImg = new ImageIcon(getClass().getResource("./flappybirdbg.png")).getImage();
    flappybirdImg = new ImageIcon(getClass().getResource("./flappybird.png")).getImage();
    topPipeImg = new ImageIcon(getClass().getResource("./toppipe.png")).getImage();
    bottomPipeImg = new ImageIcon(getClass().getResource("./bottompipe.png")).getImage();
    bird = new Bird(flappybirdImg);
    gameloop = new Timer(1000/60, this);
    gameloop.start();
    }
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    draw(g);
    }
    public void draw(Graphics g) {

    g.drawImage(backgroundImg, 0, 0, boardwidth, boardheight, null);
    g.drawImage(flappybirdImg, birdX, birdY, birdwidth, birdheight, null);
    }
    public void move() {
    bird.y += velocityY;
    }
    @Override
    public void actionPerformed(ActionEvent e) {
    move();
    repaint();
    }
    }
    This is the code. I would like to know where I have done wrong.

    • @KennyYipCoding
      @KennyYipCoding  หลายเดือนก่อน

      In the draw function, you’re not painting the bird with the bird.x and bird.y. Rather you’re doing this with birdX and birdY and those values never change. If something is not updating on the screen, it would have to be a problem with the logic in the draw or move.

    • @Commentseeker-jg8us
      @Commentseeker-jg8us หลายเดือนก่อน

      @@KennyYipCoding Thanks. It worked.

  • @KaloAk-h9o
    @KaloAk-h9o 4 หลายเดือนก่อน

    Bro is coding in 1 degree celsius; that's cool

  • @TheVibrantWild
    @TheVibrantWild 2 หลายเดือนก่อน

    You Gained An Suscribe man Thanks Alot :D

  • @karimashraf9395
    @karimashraf9395 6 หลายเดือนก่อน +3

    Hi bro, what is the best way to practice with this video ?
    I gonna divide the video into modules and stop the video and do it with myself, then continue the video
    what is your opinion about that ?
    I am a beginner in java, and this will be my first project

  • @silvermurrell5057
    @silvermurrell5057 7 หลายเดือนก่อน

    Really well made video, super interesting!

  • @TheBearCoder
    @TheBearCoder 7 หลายเดือนก่อน +1

    Hey man, i really appreciate your videos, i'm learning alot from them! However i think your collision method assumes that the bird is a rectangle, am i right ? Can you please explain the logic of how you would implement the collision method to make it more precise 🙏

    • @KennyYipCoding
      @KennyYipCoding  7 หลายเดือนก่อน +2

      So the concept of collision detection of 2D games is based on the ideal of hit boxes, which is basically a rectangle surrounding the player. It would be too difficult to get the precision down to each individual pixel. The image itself is a rectangle and the empty space is part of the image. What you can do is create another X y width height for a new hit box bird instead of using the actual bird image dimensions. This hit box would essentially be a smaller rectangle.

    • @KennyYipCoding
      @KennyYipCoding  7 หลายเดือนก่อน +2

      Another more complex solution is to divide each part of the bird with different rectangles. One for the wing, one for the head, one for the beak. And then you would loop through each hit box and do a collision check. This would be used for if you had let’s say a street fighter game, for each arm and leg, there would be a separate rectangle for collision detection since the characters are much bigger, there would be too much empty spaces in the images to just check one rectangle for the entire image.

    • @TheBearCoder
      @TheBearCoder 7 หลายเดือนก่อน

      @@KennyYipCoding Thanks for the response ❤ I'm going to surround the bird image (the black corners) with Rectangles and also add Rectangles on the pipes. Then i'm going to check if the bird corners collide with the pipes. But i'm not going to check weather the bird corners collide with the pipes all the time but rather only when the bird is close to the pipes (which is when the collision method that you implemented on this video is true). What do you think about that idea?

  • @aaravjayalwal3416
    @aaravjayalwal3416 18 วันที่ผ่านมา

    this is really good thanks

  • @subhajitgain5922
    @subhajitgain5922 5 หลายเดือนก่อน

    i like how you explain all the things.

  • @el90016
    @el90016 2 หลายเดือนก่อน

    this video really motivated me to learn object oriented programming, thanks for the video, the only think i didn't like it was that you didn't want to properly explain the collision function, was it so hard to let others understand?

    • @KennyYipCoding
      @KennyYipCoding  2 หลายเดือนก่อน +1

      I make a lot of videos that use the same collision formula. If I had to properly explain the formula every time it would be tiring. I’ve already explained everything else and as mentioned in the video, the formula checks the intersection between 2 rectangles. If you want to understand it like an engineer, you’d analyze what it does by drawing two rectangles to see how it checks for intersection. Could also look it up since it is a formula.

  • @yu-tehuang7437
    @yu-tehuang7437 8 หลายเดือนก่อน

    THank you for doing this tutorial it's pretty awesome

  • @ShubhamThakor-eh2tp
    @ShubhamThakor-eh2tp 6 ชั่วโมงที่ผ่านมา

    At 12:52 the code can't run
    Error is we can not found main method...
    So what should i do😢

    • @KennyYipCoding
      @KennyYipCoding  4 ชั่วโมงที่ผ่านมา

      there's a dropdown next to the run button that says "run Java" if you're using vscode.

  • @2gbramplayers
    @2gbramplayers 5 หลายเดือนก่อน +1

    Brhoo I completed this game coding now I am in 2nd year of first semester broo 😅

  • @cheikhndiaye2085
    @cheikhndiaye2085 หลายเดือนก่อน

    Great project 🥰

  • @thararajyam2167
    @thararajyam2167 3 หลายเดือนก่อน

    Love from India❤❤❤

  • @DankeZz
    @DankeZz 4 หลายเดือนก่อน

    Hey interesting video. What keyboard are u using for coding

  • @muhimadudin
    @muhimadudin 6 หลายเดือนก่อน +1

    Thank you for the wonderfull video...!!!

  • @rajat_809
    @rajat_809 2 หลายเดือนก่อน +1

    can anyone help me im facing an error at 12:47 its saying that main method not found i have written the code as its please help

    • @KennyYipCoding
      @KennyYipCoding  2 หลายเดือนก่อน +1

      Run the code from main file

    • @rajat_809
      @rajat_809 2 หลายเดือนก่อน +1

      @KennyYipCoding idk what the error was but when I ran it on the terminal using javac app.java flappy.java it got executed

    • @pragati-i5e
      @pragati-i5e 2 หลายเดือนก่อน +1

      ​@@rajat_809did your code run,my error is showing in 102,120 line showing illegal start of expression

  • @naveen7269
    @naveen7269 14 วันที่ผ่านมา

    hello i have knowledge on java can i try this without having any knowledge on swing or awt

  • @ChastenRamirez
    @ChastenRamirez 7 หลายเดือนก่อน

    damn sir how did you memorize all the codes . you are so pro!

  • @HoussemNirzo
    @HoussemNirzo หลายเดือนก่อน

    How to reach this level of coding skills wow

    • @Grego-xz9pt
      @Grego-xz9pt หลายเดือนก่อน

      It's really not that hard once you understand it. The hardest part is the beginning learning from scratch once you understand it it becomes very easy. It's basically learning a language and in fact lots of languages are harder to learn like mandarin

  • @bhathiyaranasinghe6637
    @bhathiyaranasinghe6637 หลายเดือนก่อน

    Thank you so much.

  • @obiku1971
    @obiku1971 8 หลายเดือนก่อน

    Thanks for this tutorial.
    Following a course on Java on uDemy and watching yours, but also other youtubers tutorials, I was wondering why during the course to instuctor is hammering on encapsulation?
    Because in 4 of these youtube tutorials concerning creating games in Java, most the varialbles are declared package private. Is encapsulatimg variables to private over exaggerated of these instructors?
    Your feedback is much appreciated and helps me to get a better understanding.

    • @KennyYipCoding
      @KennyYipCoding  8 หลายเดือนก่อน +2

      Generally it is good habit to make a data member private if it doesn’t need to be accessed outside the class, and const if the value will not change. But this is something you can do when finalizing code changes and cleaning up. For the game tutorials, I generally ignore this because I want to focus on the concepts and thought process of game programming and avoid any syntax nitpick !

    • @obiku1971
      @obiku1971 8 หลายเดือนก่อน

      @@KennyYipCoding Great feedback :) It makes completing my assignments a lot easier when I first make the assignment work and then refactor it and encapsulate what's needed.

  • @rohangurung1100
    @rohangurung1100 4 หลายเดือนก่อน +3

    Hey!, the code runs but the bird just falls down to the ground and it says gameover and i cant do anything
    help

    • @shaimashaima1702
      @shaimashaima1702 4 หลายเดือนก่อน +2

      same problem for me. can u explain how to solve this problem...

    • @MrMardalock
      @MrMardalock 2 หลายเดือนก่อน

      @@shaimashaima1702 , @rohangurung1100 - try putting
      @Override
      public void actionPerformed(ActionEvent e) {

      move();
      repaint();
      }
      @Override
      public void keyPressed(KeyEvent e) {
      if(e.getKeyCode()==KeyEvent.VK_SPACE){
      velocityY= -9;
      }
      }
      at the end of your FlappyBird class

    • @cogs7777
      @cogs7777 9 วันที่ผ่านมา

      i was having this problem with it not restarting, but i realized i needed 'birdY', not 'bird.Y', in the keyPressed method.

  • @CaiCai3
    @CaiCai3 17 วันที่ผ่านมา

    Anyone know when he started doing the code for the pipes? I have everything done except that

  • @miraclelyrics3830
    @miraclelyrics3830 2 หลายเดือนก่อน

    I have some problems in importing photos there is not any error but still I’m not able to run my codes what is the reason

  • @Y_Bicc
    @Y_Bicc 4 หลายเดือนก่อน +2

    How can I add a best score code into it?

  • @lisahensel2722
    @lisahensel2722 6 หลายเดือนก่อน

    7:51 Hi, I have a question. When I try to execute the program at this point I run into an error. In the line 15 ( Flappybird flappybird = new Flappybird(); ) the first Flappybird shows an error and I just don’t understand why. (The error message is Flappybird cannot be resolved into a type). Can someone please explain and help me?

    • @KennyYipCoding
      @KennyYipCoding  6 หลายเดือนก่อน

      Did you name the file Flappybird or FlappyBird? Note the upper case b in bird

  • @ajisam61
    @ajisam61 5 หลายเดือนก่อน

    👍Thanks!

    • @KennyYipCoding
      @KennyYipCoding  5 หลายเดือนก่อน

      Thank you for your donation! 🙏

  • @Lol99410
    @Lol99410 4 หลายเดือนก่อน

    Man this is amazing

  • @AdeptLight_Roblox
    @AdeptLight_Roblox 5 หลายเดือนก่อน

    This is good, just an opinion, i think it will be more helpful to us potato in scripting if there is a flowchart

  • @zoreladreanrivera9822
    @zoreladreanrivera9822 4 หลายเดือนก่อน +1

    I only managed to follow up until minute 19:42
    this is my error. I don't know what is missing. my imports seem to be complete
    .\FlappyBird.java:61: error: incompatible types: int cannot be converted to String
    gameLoop = new Timer(1000/60,this);
    ^
    .\FlappyBird.java:62: error: cannot find symbol
    gameLoop.start();
    ^
    symbol: method start()
    location: variable gameLoop of type Timer
    Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
    2 errors

    • @zoreladreanrivera9822
      @zoreladreanrivera9822 4 หลายเดือนก่อน

      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.util.ArrayList;
      import java.util.Random;
      import java.util.Timer;
      import javax.swing.ImageIcon;
      // import java.swing.*; // I get this error if I don't comment out this import __The import java.swing cannot be resolved__
      import javax.swing.JPanel;

    • @KennyYipCoding
      @KennyYipCoding  4 หลายเดือนก่อน +2

      It’s a different timer class. Do not import that Java.Util.timer, the timer should already be part of swing or awt when you import one of the two. Also check the completed code in the GitHub link in the video description

    • @KennyYipCoding
      @KennyYipCoding  4 หลายเดือนก่อน +2

      It’s a different timer class. Do not import that Java.Util.timer, the timer should already be part of swing or awt when you import one of the two. Also check the completed code in the GitHub link in the video description

    • @zoreladreanrivera9822
      @zoreladreanrivera9822 4 หลายเดือนก่อน +2

      ​@@KennyYipCoding so what I did wrong was that the import javax.swing.* is that I only typed import java.swing.* leaving out the x
      it literally took me 1 night to notice.
      I also deleted the other imports, I think they just pop up suddenly I you don't have the javax.swing.* import.

  • @EthioApex
    @EthioApex 7 หลายเดือนก่อน

    thank you projects really help

  • @N_Ananonymous.
    @N_Ananonymous. 8 หลายเดือนก่อน

    hi, i would like to ask if is it possible to modify the game that it would show a choices of "restart or quit" at the end of the game and shows the score of the player. Then the game speeds up after a long time. if yes, how can i do it?

  • @prensesaruaa3388
    @prensesaruaa3388 3 หลายเดือนก่อน

    It can be in phone or just desktop project?????¿???????????????

  • @ifcvf769
    @ifcvf769 5 หลายเดือนก่อน

    Damn u are actually quite patient in these comments

  • @omsable9540
    @omsable9540 10 หลายเดือนก่อน

    @KennyYipCoding what is the main method in flappy bird class

  • @doggo2821
    @doggo2821 หลายเดือนก่อน +1

    The issue with your code is likely related to the getResource() method. It returns null when it cannot locate the specified resource. Update Resource Path:
    In your project structure, the images (flappybirdbg.png, flappybird.png, etc.) are directly under the src folder.
    When using getResource(), the paths should be relative to the src folder.
    Fix the code like this:
    java
    Copy code
    backgroundImg = new ImageIcon(getClass().getResource("/flappybirdbg.png")).getImage();
    birdImg = new ImageIcon(getClass().getResource("/flappybird.png")).getImage();
    topPipeImg = new ImageIcon(getClass().getResource("/toppipe.png")).getImage();
    bottomPipeImg = new ImageIcon(getClass().getResource("/bottompipe.png")).getImage();
    Note the leading / in the paths-it denotes the root of the src directory.
    Explanation
    The issue occurs because getResource() looks for files in the runtime classpath, not the file system. If the path doesn't start with /, it is treated as relative to the package of the current class. Using a leading / ensures the path is absolute within the classpath.

  • @sanikapatil9703
    @sanikapatil9703 3 หลายเดือนก่อน

    Only Flappy bird and background is visible and Flappy bird falls down when program run
    What should i do?

  • @ajayrajpoot6315
    @ajayrajpoot6315 9 หลายเดือนก่อน +2

    the video is only 1 hour long but it took me 3 hours to watch and build this game.

    • @KennyYipCoding
      @KennyYipCoding  9 หลายเดือนก่อน +2

      that is part of learning hahaha. the video is only 1 hour long but it took me much longer to learn how to build a game in java, create a flappy bird game, record the tutorial, and edit it :)

  • @-CA-JabastinA
    @-CA-JabastinA 5 หลายเดือนก่อน

    What are the prerequisite concepts to start with this project.

    • @KennyYipCoding
      @KennyYipCoding  5 หลายเดือนก่อน +1

      You should know variables, condition statements, loops, functions, and basic knowledge of classes

  • @krale9970
    @krale9970 4 หลายเดือนก่อน

    Which Kind of theme do you use?

  • @thiferrer
    @thiferrer 4 หลายเดือนก่อน

    tks from Brazil.....see youuu

  • @leonelmessi3010
    @leonelmessi3010 7 หลายเดือนก่อน

    pipes ArrayList is added with pipes.add(topPipe); So does it mean the it is added infinitely to the pipes ArrayList? If so, then pipes.size() is infinite?
    Sorry I don't have good knowledge about these memory management since I am new at programming

    • @AzureKnight
      @AzureKnight 5 หลายเดือนก่อน

      Arraylist is allocated in heap so there is no need to allot a specific number of memory it will expand accordingly the usage

    • @leonelmessi3010
      @leonelmessi3010 5 หลายเดือนก่อน

      @@AzureKnight Thanks still a useful reply.

  • @charuka_ishan_75_
    @charuka_ishan_75_ 3 หลายเดือนก่อน

    How long time you learning java

  • @joysardar6109
    @joysardar6109 8 หลายเดือนก่อน

    Please 🥺🙏 tell me required extensions ??

  • @KarJet007
    @KarJet007 5 หลายเดือนก่อน +1

    If we done with project then how can we run in browser i min after then how can we store data and how can we earn money throw like this game's? Plz can you gide me?

    • @KennyYipCoding
      @KennyYipCoding  5 หลายเดือนก่อน +3

      The project is for education purposes and trust me, if I could earn money directly from this game itself I wouldn’t share it with you all haha

  • @SayedIqra-vo4ym
    @SayedIqra-vo4ym 4 หลายเดือนก่อน +2

    Hii i am getting the error of "Main function not declared in the class Flappybirds " Please help

    • @KennyYipCoding
      @KennyYipCoding  4 หลายเดือนก่อน

      Go to your main file and run the program from there instead

    • @baconheadhair6938
      @baconheadhair6938 4 หลายเดือนก่อน

      @@KennyYipCodingk

  • @sourasishbiswas8310
    @sourasishbiswas8310 5 หลายเดือนก่อน

    This was awesome i made it

  • @farhanahossain9970
    @farhanahossain9970 5 หลายเดือนก่อน

    hi , i am having problem in Flappybird.java section where bird = new Bird(birdimg) ; is showing error for me saying: " bird cannot be resolved or its not a field ".

    • @KennyYipCoding
      @KennyYipCoding  5 หลายเดือนก่อน

      If I had to guess, you maybe have a typo somewhere. Usually the error tells you what line the code is on, which is useful for debugging

  • @RachaitaBhattacharjee
    @RachaitaBhattacharjee 3 หลายเดือนก่อน

    In 12:53 it's say that
    The file 'FlappyBird.java' is not executable, please select a main class you want to run.
    What should I do?

    • @KennyYipCoding
      @KennyYipCoding  3 หลายเดือนก่อน

      @@RachaitaBhattacharjee go to your main file and run the code from there

  • @xlr8.tech.customs
    @xlr8.tech.customs 11 หลายเดือนก่อน

    i keep getting the error "Cannot read properties of null (reading 'length')" im only at where you spawn the first window,my code is perfect not one mistake and i dont have any plugins but the ones you told us to get in the java on vsc, what could be causing this? is there something wrong with vsc??

    • @KennyYipCoding
      @KennyYipCoding  11 หลายเดือนก่อน

      Unfortunately your code is not perfect and there is a mistake somewhere! You are trying to call length on a variable that is null. The debug console should tell you which line you’re getting the error on. Also helps to backtrack and see if you missed a step somewhere

    • @xlr8.tech.customs
      @xlr8.tech.customs 11 หลายเดือนก่อน

      @@KennyYipCoding well like i said at that point i was only like 10 lines deep so it wasnt that hard to reread everything, chatgpt, tabnine, and my 2 debuggers all said there was no issues aswel, i ennded up putting it in a different editor app and it worked fine its just specifically vsc

    • @KennyYipCoding
      @KennyYipCoding  11 หลายเดือนก่อน

      Ah interesting, not sure why you’re getting the issue in vscode. If you copy and paste the completed code into your java project, do you still get the same issue?

    • @xlr8.tech.customs
      @xlr8.tech.customs 11 หลายเดือนก่อน

      @@KennyYipCoding on vsc i dont get anything not even an error, on normal vs it works, im not sure whats going on but i just uninstalled it

  • @shaimashaima1702
    @shaimashaima1702 4 หลายเดือนก่อน

    how can I make the flappy bird wing move up & down like a bird ..beacuse my code is execute but flappy bird is falling down how to control ....

    • @KennyYipCoding
      @KennyYipCoding  4 หลายเดือนก่อน +2

      You cannot do it with one image. Making the flappy bird wings move up and down is called animation. You need multiple images of the bird with the wings in different positions.

  • @rahulshrestha1568
    @rahulshrestha1568 11 หลายเดือนก่อน

    How do i keep my high score saved and have a start a new game button

    • @KennyYipCoding
      @KennyYipCoding  11 หลายเดือนก่อน +1

      depends, if you want to keep track of the high score only when you open the program, you can create another variable to keep track of that.
      However if you want to keep track of high score permanently, so that it remembers every time you run a new instance of the program, you'd need to write and read that information, such as with a txt file

  • @isabellefrancisco7179
    @isabellefrancisco7179 9 หลายเดือนก่อน

    Does the code only run in visual studio? It doesn't seem to work in NetBeans

    • @KennyYipCoding
      @KennyYipCoding  9 หลายเดือนก่อน

      I’ve never used net beans so not sure what the project setup is like. Try creating a project in net beans and writing the code from there.

  • @schroedingers838
    @schroedingers838 9 หลายเดือนก่อน

    Hello! Today (11 May 2024) the game seems to be very hard and sometimes impossible to win: pipes are placed very near horizontally and sometimes empty space between two pipes does not connect contiguously to the empty space of the horizontally following two pipes. Could it depend on the random components that today make it be so hard? In particular, yesterday all was normal and playable, both in my pc and in your website, and today the same issue there is both in my local run and in the one in your website.

    • @KennyYipCoding
      @KennyYipCoding  8 หลายเดือนก่อน

      Do you mean the java version or the js version ?

    • @schroedingers838
      @schroedingers838 8 หลายเดือนก่อน

      @@KennyYipCoding The js version, and later a couple of hours that I wrote the message, it happened that the played returned "normal", with the pipes at the right distance... I did not understand if the issue depended from the randomness or from something in my browser.

    • @KennyYipCoding
      @KennyYipCoding  8 หลายเดือนก่อน +1

      Hmm interesting, it could be the random function. Math.random() is pseudo random so it uses the system time with a deterministic algorithm

    • @schroedingers838
      @schroedingers838 8 หลายเดือนก่อน

      @@KennyYipCoding It was funny because I used your template to do an happy birthday variation of the game in which I replaced the bird with the picture of the cat of a friend of mine and then I added a condition that after a number of pipes equals to her new age the game was win with an Happy Birthday message. And it was such hard that to make it possibile for her to win I had to modify parameters because at the hour I sent it to her, the game was almost impossible to win😬

  • @kinglisi
    @kinglisi 4 หลายเดือนก่อน

    The whole reason I watched was to see how you handle rotation because it seems to be heavy doing it in the draw function, and that's the only rhing you skip cry 😢

  • @chiku6964
    @chiku6964 3 หลายเดือนก่อน

    Sir it Throw an error that main method is not define how can i improve this

    • @KennyYipCoding
      @KennyYipCoding  3 หลายเดือนก่อน

      Run the code from your app main file and not the flappy bird file

    • @chiku6964
      @chiku6964 3 หลายเดือนก่อน

      @@KennyYipCoding Then it throws an expectation of Nikl pointer I have tried to much time but I can't understand that expectations

    • @chiku6964
      @chiku6964 3 หลายเดือนก่อน

      @@KennyYipCoding respected Sir will you provide me your Instagram I'd I will send error ....

  • @robtai6225
    @robtai6225 7 หลายเดือนก่อน

    can you give a tutorial on platformer?

  • @jaywagh1527
    @jaywagh1527 5 หลายเดือนก่อน

    Sir I didn't get the blue panel it shows error code is ecxtaly like you no another line so why it is show me error like this

    • @KennyYipCoding
      @KennyYipCoding  5 หลายเดือนก่อน

      What does the error say? It should tell you what the error is and the line you’re getting the error from.

  • @Pablo-e7c5s
    @Pablo-e7c5s 3 หลายเดือนก่อน

    thank you sir

  • @animer1692
    @animer1692 หลายเดือนก่อน

    Can this be made on blueJ

    • @KennyYipCoding
      @KennyYipCoding  หลายเดือนก่อน

      @animer1692 you can, you just need java. But I would use vscode as recommended.

  • @sumitsnaps
    @sumitsnaps 2 หลายเดือนก่อน

    thanks sir

  • @sadiulhakim7814
    @sadiulhakim7814 6 หลายเดือนก่อน

    I cannot believe that i made a game today. I cannot even make 20 score in this game.

  • @musicyoutube9797
    @musicyoutube9797 4 หลายเดือนก่อน

    nice video!

  • @HuỳnhTrầnThiênAn
    @HuỳnhTrầnThiênAn 11 หลายเดือนก่อน

    how can I make the flappy bird wing move up & down like a bird

    • @KennyYipCoding
      @KennyYipCoding  11 หลายเดือนก่อน

      You would need an animated gif for that

    • @mobbs8229
      @mobbs8229 28 วันที่ผ่านมา

      or an image for when the bird is moving up and down, right?​@@KennyYipCoding

  • @Everything-Java
    @Everything-Java 4 หลายเดือนก่อน

    So cool😊

  • @trsk
    @trsk 7 หลายเดือนก่อน

    thank you sir....

  • @abhimudam27
    @abhimudam27 12 วันที่ผ่านมา

    Iam getting null pointer exception location is null error..
    Pls help me

    • @KennyYipCoding
      @KennyYipCoding  12 วันที่ผ่านมา

      read the error!!
      It tells you what line the error is on. Usually this happens when you try to access a variable that has a null value (has not been assigned a value or object)

    • @abhimudam27
      @abhimudam27 12 วันที่ผ่านมา

      @KennyYipCoding Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.net.URL.toExternalForm()" because "location" is null

  • @nikhilgaming1567
    @nikhilgaming1567 7 หลายเดือนก่อน

    How to add sounds to background

  • @taitekrogfus1382
    @taitekrogfus1382 10 หลายเดือนก่อน

    Am i able to still code this on eclipse IDE?

  • @Yash-gangurde310
    @Yash-gangurde310 7 หลายเดือนก่อน

    It is not a working mobile phone i have done coding as u said and i hosted them also but none of flappy bird , 2048, and candy crush work on mobile phone 😢

    • @KennyYipCoding
      @KennyYipCoding  7 หลายเดือนก่อน +1

      well you have to understand why they don't work on mobile. It's just not in the code. You have to write the code to make something work.
      Theres no key being pressed on your phone, no space bar being pressed to make the flappy bird jump. There's no arrow keys being pressed to move the 2048 tiles. You would have to implement buttons on the web page to process these events.
      Also mobile web pages don't support drag and drop ui components well. There's probably a library or something out there that you can use to process drag drop events.
      In general, a laptop is not the same environment as a mobile phone, so a website would function differently. That's where mobile apps come in. If you want to make a game playable on the phone, it would have to be a mobile app, which is out of the scope of these tutorials. Nobody plays mobile games on a website, they play through applications. 🙂

    • @Yash-gangurde310
      @Yash-gangurde310 7 หลายเดือนก่อน

      @@KennyYipCoding you are correct they working flawless on my laptop 💻 btw thanks for your playlist of JavaScript game development 🙏🏻

    • @Yash-gangurde310
      @Yash-gangurde310 7 หลายเดือนก่อน

      Actually i hosted them free on the web so i just wanted to share with my friends to show them but i tried before and they are not working so i worried i will try to modify them for mobile phone 👍🏻

  • @abhisheksah2010
    @abhisheksah2010 9 หลายเดือนก่อน

    how can I get a demo of it?

  • @bubule_
    @bubule_ 11 หลายเดือนก่อน

    12:53 i don't no why the back ground is not there only one white rectabgle, i have made all the step

    • @KennyYipCoding
      @KennyYipCoding  11 หลายเดือนก่อน +1

      You should backtrack to see which line you made an error on. You probably didn’t add the JPanel to the Jframe in the main file or something. I have the completed code in the GitHub link for you to compare to

    • @bubule_
      @bubule_ 11 หลายเดือนก่อน

      @@KennyYipCoding thanks i gonna see

  • @ssmaragdine6018
    @ssmaragdine6018 8 หลายเดือนก่อน

    May I ask How can I export to IOS app? Thanks

  • @robtai6225
    @robtai6225 8 หลายเดือนก่อน

    thank you sooso much!

  • @AgentCarp
    @AgentCarp 4 หลายเดือนก่อน +1

    the fps of the game decreases on key press

  • @eckartmuller151
    @eckartmuller151 7 หลายเดือนก่อน

    perfect expression

  • @rudrarupsingha2678
    @rudrarupsingha2678 หลายเดือนก่อน

    Bro where is the app class folder

  • @JotaroKujo-xx5uu
    @JotaroKujo-xx5uu 8 หลายเดือนก่อน

    what program is this ?

    • @KennyYipCoding
      @KennyYipCoding  8 หลายเดือนก่อน

      vs code

    • @JotaroKujo-xx5uu
      @JotaroKujo-xx5uu 8 หลายเดือนก่อน

      ​@@KennyYipCodingis it free ?

    • @KennyYipCoding
      @KennyYipCoding  8 หลายเดือนก่อน

      Yes, as mentioned in the video, if you check the description, there’s a link to the video for how to setup java in vscode

  • @ishakumari457
    @ishakumari457 8 หลายเดือนก่อน

    Thank you!!

  • @МаріаннаБенькалович
    @МаріаннаБенькалович 6 หลายเดือนก่อน

    very good

  • @DariusAul
    @DariusAul 8 หลายเดือนก่อน +1

  • @Rp7gameryt
    @Rp7gameryt 3 หลายเดือนก่อน +1

    Nobody has the problem when the bird is drawn on the screen , It is super large?
    I thought i made a mistake in the code but i couldn't find any error in anything..
    Thats when i checked the dimensions of the bird image and its not 34x24..
    Its something bigger..

    • @KennyYipCoding
      @KennyYipCoding  3 หลายเดือนก่อน

      When drawing the image you specify an x y width and height. The image will be scaled down

    • @Rp7gameryt
      @Rp7gameryt 3 หลายเดือนก่อน

      @@KennyYipCoding yeah..
      I found the problem...
      I put the width and height of the screen..
      Which made the bird enormously huge lol

  • @kaifkazi7521
    @kaifkazi7521 4 หลายเดือนก่อน +1

    Anyone... Is it runs?

  • @Manu-dx1ob
    @Manu-dx1ob 8 วันที่ผ่านมา

    7:33