Full Screen Mode - How to Make a 2D Game in Java #34

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии • 139

  • @FrankLeRouxe
    @FrankLeRouxe 21 день назад +2

    If you have problem with "CLASS SELECTION SCREEN" remember to put "g2.setColor(new Color(0, 0, 0));" and "g2.fillRect(0,0,gp.screenWidth,gp.screenHeight);" outside "if(titleScreenState == 0)" statement in drawTitleScreen method. Thank you RyiSnow for those precious video!

  • @sorcerian_bootleg7112
    @sorcerian_bootleg7112 2 года назад +30

    Every piece of this series is interesting and deserves attention.
    Let me tell you something that maybe you've been told already: your videos not only are great for those of us who are learning Java, but also they help to put my mind at ease. I don't know if i'm the only one, but your slow and calm pacing is somehow relaxing/relieving! :D
    Stay well!

    • @RyiSnow
      @RyiSnow  2 года назад +5

      Haha that wasn't intended but I'm glad to hear that nonetheless!

  • @aidenwalmer
    @aidenwalmer 2 года назад +8

    Was just wondering about full screen implementation, came at the perfect time! Keep up the great work RyiSnow 🔥👊🏻

  • @kikismine
    @kikismine 2 года назад +2

    Nice new video about the best Java Programming Game Tutorial from RyiSnow!! I love it!

  • @holmdev
    @holmdev 2 года назад +4

    I'm thinking about trying to add a mini map, but I don't know how yet, but it's probably going to go. Thanks for a good series

    • @RyiSnow
      @RyiSnow  2 года назад +5

      Mini map is actually in the plan. You can actually apply the method that we did in this video to create a mini map. Create a buffered image and draw the whole map on it. Then you just need to resize it :)

    • @holmdev
      @holmdev 2 года назад +2

      @@RyiSnow yes i made it work like that.

  • @BracamonteL
    @BracamonteL 3 месяца назад +1

    my dreams have your voice now

  • @elvispontes4165
    @elvispontes4165 2 года назад

    It is so great of you to share this totorial. Thanks a lot!!.

  • @Merkuse
    @Merkuse 2 года назад +3

    Hello RyiSnow. You series are great and your calmy voice making it more cool. Its a really interesting to see how making game with out engines. Just from zero point!
    I was about to question you how to implement one feature but then I just think "Hey, me! What about you do it on yourself ?" and I did it! Because you not only writing code but also explaining it ! Thank you for your videos! Also dont you think to run a parteon or smth like that ?

    • @RyiSnow
      @RyiSnow  2 года назад +1

      I'm very happy to hear that. Yeah, thinking by yourself is a very important ability in coding. It helps you greatly to improve your skill and expand possibilities. Keep it up!

  • @maciejsosnowski4757
    @maciejsosnowski4757 2 года назад +24

    To anyone who struggles with dramatic fps drop in full screen I found solution or maybe more of a hack. For full screen stuff I replaced setFullScreen() with this below. No FPS drops.
    public void setFullScreen() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    double width = screenSize.getWidth();
    double height = screenSize.getHeight();
    Main.window.setExtendedState(JFrame.MAXIMIZED_BOTH);
    screenWidth2 = (int) width;
    screenHeight2 = (int) height;
    //offset factor to be used by mouse listener or mouse motion listener if you are using cursor in your game. Multiply your e.getX()e.getY() by this.
    fullScreenOffsetFactor = (float) screenWidth / (float) screenWidth2;
    }

    • @patrickdavies4113
      @patrickdavies4113 Год назад

      I thought I ruined my game! Thank you, absolute lad

    • @miguelz8122
      @miguelz8122 Год назад

      Thank you so much man

    • @i_say_uhh
      @i_say_uhh 10 месяцев назад

      Thanks so much! I was getting a slide show for a game lol

  • @PedroHenrique-hy7yw
    @PedroHenrique-hy7yw 2 года назад +3

    I'm not that interested in game develpment at all, but still, your videos are really cool. I love to see those stuff being built from scratch. Keep um the good work!

    • @RyiSnow
      @RyiSnow  2 года назад

      That's great to hear! Thank you for the comment :D

  • @luciuscouto4592
    @luciuscouto4592 2 года назад +4

    When I did this, when I get to the edge of the map, the game crashes and gives some design problems like: when I open the inventory and close the inventory, it keeps showing up, do you have any idea how to solve it?

    • @rexroyulada6267
      @rexroyulada6267 8 месяцев назад

      I'm having the same issue right now.

    • @diegodiaz5787
      @diegodiaz5787 3 месяца назад

      @@rexroyulada6267 you can solve it? the problem its the screen isnt redrawing

  • @BunnyMasterRBLX
    @BunnyMasterRBLX 2 года назад +3

    Love your videos! can you add a water animation if you can that would look awesome in the game

  • @harisclientisskidded
    @harisclientisskidded 2 года назад +3

    Hello RyiSnow, when i run the game, it sets to fullscreen, but its blank and i cant exit from it. Could you help me?

  • @garciajushua724
    @garciajushua724 18 дней назад

    finally im in this part now! the FULLSCREEN MODE!!😍😍😍

  • @oriooom
    @oriooom 2 года назад +4

    Hi RyiS! I'm wondering how to implement animated tiles and weather. For weather, maybe an overlay of animated rain during rainy days or flowing leaves during windy days. I'm also wondering what do you call those?

  • @lucaxtal
    @lucaxtal 2 года назад +2

    You are doing a great work in your development. The game is coming to life!! I'm following you from your start. Great Job!! Could I suggest you also at some point in the future to try also JavaFX? I'm using it for small game development and there are more nice features than in the default Swing library without adding complexity.

    • @RyiSnow
      @RyiSnow  2 года назад +7

      Glad you enjoy the series! Sorry but JavaFX is not in my plan since I'm not a big fan of it. If I make a tutorial with external libraries/framework I think I would choose LWJGL or LibGdx.

  • @stratfender89
    @stratfender89 Год назад +5

    So, after loading the game to the screen, I suffer a lot of performance issues for a while. However, after moving around a bit, the performance picks up back to normal. Is anyone else experiencing this and if so what is their fix?

    • @kimabram
      @kimabram Год назад +1

      Mine, the tiles on the side are bugging. Changing colors.

  • @greatblackshark9646
    @greatblackshark9646 2 года назад +2

    I love these tutorials! I was wondering though how you'd render a building on the map, like a house or a cave. Is that something you'd layer on top of the completed map or something you'd do tile by tile? I'm thinking the first but don't know how.

    • @laxuspoldish6165
      @laxuspoldish6165 2 года назад

      You could break up the tile/grid system into two layers. Bottom layer being the terrain layer such as grass, water, dirt, etc. Then have a design layer such as houses, structures, etc, which would be on top of the terrain layer

    • @greatblackshark9646
      @greatblackshark9646 2 года назад

      @@laxuspoldish6165 I see. Thank you. I'll look into that

  • @itisajem8645
    @itisajem8645 2 месяца назад

    Hey RyiSnow I was having a problem with my code where When I try and run the game in full screen or when I increase the scale the games FPS tanks to like 40 to 20 and I have tried everything to get it to run faster but nothing has worked. if there is any advice or help you could offer it would be greatly appreciated. I love your videos, they are so comforting and informative.

  • @hikkaru9751
    @hikkaru9751 2 года назад +2

    Yo, your tutorial is so good! Thanks for your job. Is there any other way to make fullscreen? With this code my title screen not working. Screen shows the menu but it's frozen and in the right corner it shows small part of the menu again covering part of "quit" option. When i skipped title screen i could play normaly but drawing time is few times worse.

  • @harllemalves1590
    @harllemalves1590 2 года назад +4

    Hello RyiSnow, you can teach to us how to implement an Battle System like Final Fantasy I (Turn Based) using this engine?

    • @RyiSnow
      @RyiSnow  2 года назад +8

      I'd love to if I have more time!

  • @filippo61
    @filippo61 Год назад +1

    Hi Ryi, I encountered a problem : the 2nd menu ( fighter, thief, etc) is displayed below the first one .

    • @MegaHihat
      @MegaHihat Год назад +1

      In method "drawToTempScreen()" first string is "super.paintComponent(graphics2D);". I had the same problem. It helped me. Good luck!)

  • @diegodiaz5787
    @diegodiaz5787 3 месяца назад +1

    I have a problem. I changed to the new method nad now the screen isnt repainting.
    It paints the corrects images and text but isnt changing the past frames. Someone have the same issue?

    • @diegodiaz5787
      @diegodiaz5787 3 месяца назад +1

      For everyone who has this problem using the WHILE method to draw the screen.
      I added this line [g2.clearRect(0, 0, screenWidth2, screenHeight2);] at the begining of the drawToTempScreen method. This fixed the problem

    • @diegodiaz5787
      @diegodiaz5787 3 месяца назад

      this, clears the screen everytime the method is called in the loop, so rewrites the correct frames. If enyone knows others ways to solve this, it will be great to know ;)

    • @Trollycat1822
      @Trollycat1822 2 месяца назад +1

      @@diegodiaz5787omg thank you so much I was so scared cause when I pressed down to go to like load save or quit game it kept drawing the thing😊

    • @diegodiaz5787
      @diegodiaz5787 2 месяца назад

      @@Trollycat1822 🤙

    • @theotsif9561
      @theotsif9561 Месяц назад

      @@diegodiaz5787 legend, this fixes everything , huge thanks

  • @marekbalaz32
    @marekbalaz32 2 года назад +1

    Hellou , i need some help , I implemented full screen and if i started game my fps raise to 160 and my game is too fast ... and when i m in fullscreen mode then fps are so slow and game too .... i dont know ... some advice ? thanks

  • @chathoth-m3r
    @chathoth-m3r 7 месяцев назад

    Always I am allowed to reference. May I ask you one question? If checked, the screen will flash black. Do you know what the cause is?

  • @bigclashrayle29
    @bigclashrayle29 2 года назад +1

    Hi RyiSnow what if my is computer, because when I set up to full screen and my screen is black. What should I change my code to.

  • @Mrtargi
    @Mrtargi 2 года назад +3

    So I triple checked, this full screen features totally ruins my game menu and graphics as well(((

  • @Mrtargi
    @Mrtargi 2 года назад +5

    Amazing! But there is a bug when you re trying to switch between New game etc

    • @leonelpereira2624
      @leonelpereira2624 Месяц назад

      Hi man, i have the same problem, you know how to fix it?

  • @chrisfeasby7528
    @chrisfeasby7528 Год назад

    Hey loving your tutorials yet when I reach the point where paint component is removed and everything is as it is in yours my screen starts up okay with title menu but once going in things are not right as they are overlapping the fighter selection and once in game its flashing black in the game? I'll try to continue / edit out the changes for now.. hopefully you know what is going on?

  • @Mozartminecraft
    @Mozartminecraft 10 месяцев назад

    Why does 'GraphicsEnvironment' not resolve? I imported it and there is an error in the list of imports: cannot resolve graphics environment.

  • @WoodsGeorgeJr
    @WoodsGeorgeJr 2 года назад +2

    yes this helps so much!!!

  • @FerodriEste
    @FerodriEste 2 года назад +1

    Hello Ryi, amazing video as always!!!
    I would like you to develop the functionality when the character runs out of life, some game over screen or something

    • @RyiSnow
      @RyiSnow  2 года назад +2

      Yup the game over screen will be implemented in the near future.

  • @aarushkumar168
    @aarushkumar168 2 года назад +1

    Can you please make the next video on saving and loading the game?

  • @NatyTor
    @NatyTor 2 года назад

    ho man! your videos are amazing!!💕💕

  • @oguzhantopaloglu9442
    @oguzhantopaloglu9442 2 года назад

    This was really good

  • @greatblackshark9646
    @greatblackshark9646 2 года назад

    Not sure if this was answered in a previous video but thought I'd ask first. Is there a way to give Half of a tile collision detection and the other half able to be walked through. Like say you have a shore tile with half sand half water.

    • @RyiSnow
      @RyiSnow  2 года назад +1

      Set a solidArea to the tiles. You'll also need to edit the checkTile method so it can intersect rectangles.

    • @greatblackshark9646
      @greatblackshark9646 2 года назад

      @@RyiSnow ok. I'll try to figure that out

    • @lvdv4j
      @lvdv4j Год назад

      @@greatblackshark9646 Were you able to figure it out? I'm also trying to do something like this

  • @jay_codes
    @jay_codes 2 года назад

    Great video Was always curious on how to go full screen using java built in Graphics class

  • @j_and_v_switch
    @j_and_v_switch Год назад +1

    If you don't want to change the game ratio from 4:3 to 16:9:
    public void drawToScreen() {
    Graphics g = getGraphics();

    // Calculate the aspect ratio
    double screenRatio = (double) fullScreenWidth/fullScreenHeight;
    double gameRatio = (double) screenWidth/screenHeight;
    // Calculate the size of the black bars
    int barWidth = 0;
    if (gameRatio < screenRatio) {
    barWidth = (fullScreenWidth - (int)(fullScreenHeight * gameRatio)) / 2;
    }
    // Draw the black bars
    g.setColor(Color.BLACK);
    g.fillRect(0, 0, barWidth, fullScreenHeight); // Left bar
    g.fillRect(fullScreenWidth - barWidth, 0, barWidth, fullScreenHeight); // Right bar
    // Draw the game screen
    g.drawImage(tempScreen, barWidth, 0, fullScreenWidth - 2 * barWidth, fullScreenHeight, null);
    g.dispose();
    }

  • @rianoliveira5378
    @rianoliveira5378 2 года назад +1

    please continue with the subtitles/transcript of the video 🥺

    • @RyiSnow
      @RyiSnow  2 года назад +2

      They are auto-generated by RUclips. Not by me. I know some videos don't get subtitles but I have no idea why.

    • @rianoliveira5378
      @rianoliveira5378 2 года назад +2

      ​@@RyiSnow oh,sorry, didn't know about that part. But it's ok. Thanks for the video.

  • @anonymus_the_real
    @anonymus_the_real 2 года назад

    it could be like going down a flight of stairs to the basement and defeating a big boss. And do you do a tutorial if you go to a height like a cellar then you have a new background?

  • @andrasfejes8988
    @andrasfejes8988 2 года назад +2

    After the settings the titleScreenState 1(main title) ---> titleScreenState 2(Select your class!) changing is not happening. (You can see both at the same time)
    What should I do?

    • @TheFenzakosu
      @TheFenzakosu Год назад +8

      I've filled the screen (fillRect) again after if statement in UI class , in order to reset it.
      public void drawTitleScreen() {
      if (titleScreenState == 0) {
      ....
      }
      else if (titleScreenState == 1) {
      ADDED -----> g2.setColor(new Color(0, 0, 0));
      ADDED ------> g2.fillRect(0, 0, gp.SCREEN_WIDTH, gp.SCREEN_HEIGHT);

      // CLASS SELECTION SCREEN
      g2.setColor(Color.white);
      g2.setFont(g2.getFont().deriveFont(42F));
      String text = "Select your class!";
      int x = getXforCenteredText(text);
      int y = gp.TILE_SIZE * 3;
      g2.drawString(text, x, y);
      }
      }
      Seems to work fine for me now.

    • @michaelharrington5860
      @michaelharrington5860 Год назад

      @@TheFenzakosu This works on Mac in conjunction with setting BufferedImage.TYPE_INT_ARGB_PRE. Thank you sir!

  • @andrasfejes8988
    @andrasfejes8988 2 года назад

    Anyway, where is the subtitle screen (thief, sorcerer, etc.) ?

  • @aarushkumar168
    @aarushkumar168 2 года назад +1

    What's coming next after this series is finished 👀

    • @RyiSnow
      @RyiSnow  2 года назад +5

      I will think about it when this series is done!

  • @dutianze
    @dutianze 2 года назад +3

    tips: mac user can use command+Q to exit, and for anyone else screen is black, try to use BufferedImage.TYPE_INT_ARGB_PRE

    • @cxztus
      @cxztus Год назад +2

      THANK YOU SO MUCH, I WAS TRYING TO FIGURE THIS OUT FOR THE PAST 3 DAYS, THANK YOU!

  • @santanabarman7946
    @santanabarman7946 2 года назад

    Can you told in which video you change the run method
    If possible give link

  • @woodswoody5553
    @woodswoody5553 2 года назад +7

    Anyone elses screen just black I hate saying somethings wrong but I cant even put a finger on it. Everything looks exactly the same in implementation. I have redone the tutorial 3 times

    • @parunev
      @parunev 2 года назад +3

      Similar problem here.

    • @willc5177
      @willc5177 2 года назад

      Lol same

    • @dutianze
      @dutianze 2 года назад +5

      try to use BufferedImage.TYPE_INT_ARGB_PRE

    • @woodswoody5553
      @woodswoody5553 2 года назад

      @@dutianze ok

    • @woodswoody5553
      @woodswoody5553 2 года назад +1

      @@dutianze This works ryi should pin this somehow

  • @talaniel
    @talaniel 10 месяцев назад

    Instead of alt+tab and kill, it is posible to close the app using alt+f4 I believe.

  • @thatspella
    @thatspella 2 года назад

    I've tried to implement this into my game, but it seems like the quality of the screen is much worse than before (the title strings and another sprites look much more pixelated). It also drastically reduces the performance of my game, isn't there a less heavier way to implement full screen?

    • @woodswoody5553
      @woodswoody5553 2 года назад

      you can manually add all the new sizes to eevrything instead of redrawing the game twice but it takes awhile so for now I just skipped this and might come back later after reduce drawing time through debug

    • @thatspella
      @thatspella 2 года назад

      @@woodswoody5553 I tried but it doesn't seem to work properly

    • @woodswoody5553
      @woodswoody5553 2 года назад +2

      Maybe Ryi will make another debug video to maintain the integrity of the game while keeping the frame rate good and draw time low

  • @purpleconvict4152
    @purpleconvict4152 2 года назад

    こんばんは! I have a few questions. How can I add screen transitions? Maybe from the overworld into an NPC home? How can can I add unique music to the title screen? How can I add NPC dialogue sound effects? And how can I add dialogue options for the player? Thank you!

    • @RyiSnow
      @RyiSnow  2 года назад +3

      The screen transitions and the dialogue options will be featured in future videos. For playing different sound we've already done many times throughout this series so please check previous videos.

    • @purpleconvict4152
      @purpleconvict4152 2 года назад

      @@RyiSnow ありがとう! Also, i am having a bug with map loading. I Have followed your tutorials but for some reason, my map doesn't change when I edit the world.txt file. Even if I delete the world.txt, the map doesn't change. It just draws the tile assigned to 0 in a to the maxWorldCol and the maxWorldRow. So a 50 x 50 radius. Please help!

    • @Merkuse
      @Merkuse 2 года назад +2

      @@purpleconvict4152 program in the tutorial reads worldV2.txt.

    • @purpleconvict4152
      @purpleconvict4152 2 года назад

      @@Merkuse I fixed this a while ago but thanks for trying to help! :)

  • @parunev
    @parunev 2 года назад

    I followed the tutorial step by step and everything is equal to yours but my screen is black. Any suggestions? Using MacOs and IntelliJ

    • @RyiSnow
      @RyiSnow  2 года назад +2

      Hmm sorry but I'm not so sure since I don't own Mac. If your code is indeed correct, it might be a Mac related issue so maybe you want to google it. I don't think IntelliJ is the problem.

    • @paul7408
      @paul7408 2 года назад +1

      Im running to this issue as well, I think my issue is i am using a 3440 X 1440 monitor.

    • @woodswoody5553
      @woodswoody5553 2 года назад +1

      @@paul7408 similar problem

    • @woodswoody5553
      @woodswoody5553 2 года назад +1

      same issue

  • @raghavgoyal8789
    @raghavgoyal8789 2 года назад

    When will you post the next video?

  • @cedricsahaghian1605
    @cedricsahaghian1605 Год назад

    Thanks RyiSnow!

  • @bigclashrayle29
    @bigclashrayle29 2 года назад

    Hi RyiSnow do you know what is 5120-by-2880?

  • @bluethemcguy4430
    @bluethemcguy4430 2 года назад

    What would be the code to make the Full Screen Window back into a normal Sized Window? (Like window.setDefaultSize() or something )

    • @RyiSnow
      @RyiSnow  2 года назад +1

      Here's the line for that: gd.setFullScreenWindow(null);
      It works just fine if you keep the top bar while in full screen but if you have undecorated the JFrame, you cannot restore the top bar unless you recreate the JFrame. We'll handle this full screen on/off function in the next video.

  • @FerodriEste
    @FerodriEste 2 года назад

    Hi Ryi after to implements this changes, when start the game, the second screen (when you choise a class figther, sorcerer or thief) is off-center with respect to the first screen. But then the game is fine.

    • @RyiSnow
      @RyiSnow  2 года назад +1

      We changed the screen ratio so it's only natural that some UI elements jolt out of alignment. As I did for the inventory screen in this video, you need to adjust them so they fit the wider screen.

  • @Mypremiumacct
    @Mypremiumacct Месяц назад

    I am so immersed rn

  • @tophyy906
    @tophyy906 Год назад

    Hello, I'm having an issue after this video that the game is crashing with the error - Exception in thread "Thread-0" java.lang.NullPointerException: Cannot read field "image" because "this.tile[tileNum]" is null. It does this whenever I'm at the bottom left area of the map.
    edit** I'm an idiot I only just realised this was an issue but its one I've had for a long time apparently if you have this make sure you are on the correct map (I assume no one is dumb like me but just in case) be on mapV2

  • @abtinabolhosseiny4741
    @abtinabolhosseiny4741 2 года назад +2

    That was so so so good thank you for your videos and please make a video about how to turn our java file from example.java to a example.exe i mean how to create a launcher for our Java program 👍

    • @RyiSnow
      @RyiSnow  2 года назад

      You can export it as a jar file.

  • @aarushkumar168
    @aarushkumar168 2 года назад +1

    How to check NPC to NPC collision?

    • @knightking5735
      @knightking5735 Год назад

      put this in entity class in the update method :
      gp.cChecker.checkEntity(this, gp.npc);

  • @Nienawidzoncy
    @Nienawidzoncy 2 года назад +5

    Is it just me or the FPS in fullscreen dropped crazy?

    • @bluethemcguy4430
      @bluethemcguy4430 2 года назад +1

      For me too

    • @MasonJarFilm
      @MasonJarFilm 2 года назад +1

      Me too. my draw time without full screen is around 2.8 mill. With full screen it is 5-12 mill

  • @2MSTennis
    @2MSTennis 2 года назад

    Hey Ryi! いつもお世話ににります!
    How could I go about doing a cutscene? Have you experimented with that yet?
    宜しくお願い致します。
    ケイ

    • @RyiSnow
      @RyiSnow  2 года назад

      I sort of created a cutscene in the Farewell 2021 video. I scripted the camera and the characters movement. How you do it is really depends on what kind of cutscene you create. Basically you need to script what you want to do on the screen. Creating a class for that would be handy.

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 года назад

    Thanks!

  • @wonderzhou662
    @wonderzhou662 2 года назад

    I tried to switch to tempScreen but somehow I cannot change it successfully. I think I need to skip this part. Also, I still keep with stop moving the camera at the edge of map.
    For now, I can build a jar file without any big problem.

    • @RyiSnow
      @RyiSnow  2 года назад +1

      No worries. Full screen is just optional so you can continue the series without this!

    • @wonderzhou662
      @wonderzhou662 2 года назад +1

      @@RyiSnow It seems like it is not hard to implement it, but I cannot achieve it, which makes me feel annoyed.

  • @watermelon-loves-you1236
    @watermelon-loves-you1236 2 года назад

    What is name of this game i want to play

  • @aliasgarjiwani6898
    @aliasgarjiwani6898 2 года назад

    After this update i dont know why but its lagging

  • @kamisama1712
    @kamisama1712 2 года назад +2

    Anyone else having screen tearing issues after changing to full screen? Anything that’s out of bounds ends up looking glitched out.

    • @Aashvark
      @Aashvark 2 года назад +1

      thats what happened to me before, but after following this video my player speed was slowed

  • @Wernix228
    @Wernix228 2 года назад

    Top 👍

  • @ProjCRys
    @ProjCRys Год назад

    I'll drop this code for anyone who finds this useful.
    The purpose of this code is to prevent the game from slowing down in case of the FPS drops (basically it goes like into slow motion) or speeding up if FPS goes past a certain point.
    public void run() {
    long lastTime = System.nanoTime();
    long currentTime;
    double delta = 0;
    double updateInterval = 1.0 / FPS;
    long timer = 0;
    int drawCount = 0;
    while (gameThread != null) {
    currentTime = System.nanoTime();
    delta += (currentTime - lastTime) / 1000000000.0; // Convert nanoseconds to seconds
    lastTime = currentTime;
    while (delta >= updateInterval) {
    // Update
    update();
    delta -= updateInterval;
    }
    // Draw
    drawToAlteredScreen(); // Draw game into buffered image
    drawToScreen(); // Draw buffered image to screen
    drawCount++;
    if (keyH.showDebugText && (System.nanoTime() - timer) >= 1000000000) {
    currentFPS = drawCount;
    drawCount = 0;
    timer = System.nanoTime();
    }
    }
    }

  • @winhax4344
    @winhax4344 Год назад

    Since I am coding in Android Studio, this is unnecessary. Thank you in advance, if I do this in Java!

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Год назад

    🥰🥰🥰

  • @bigclashrayle29
    @bigclashrayle29 2 года назад

    That is my computer size.

  • @solarcubing7504
    @solarcubing7504 2 года назад +1

    Pov u asked for this 1:39

    • @solarcubing7504
      @solarcubing7504 2 года назад

      Also regarding a previous comment abt map changing I figured it out what I did was remake the map tile class and .ovd the player according to the map spawn and made a door clàss

  • @kapa9436
    @kapa9436 2 года назад +1

    Hey RyiSnow, i have an issue with the full screen: when my game is in full screen, my graphics card takes over and the whole game speeds up a lot (player go faster, Counters go faster...)in addition to unstable fps, high then low... how can i fix that ? thanks in advance
    My code:
    @Override
    public void run(){
    // FPS = 60;
    // final double drawInterval = 1000000000/FPS;
    double drawInterval = 1000000000/FPS;
    double delta = 0;
    long lastTime = System.nanoTime();
    long currentTime;
    long timer = 0;
    int drawCount =0;
    while(gameThread != null){
    currentTime = System.nanoTime();
    delta += (currentTime - lastTime) / drawInterval;
    timer += (currentTime - lastTime);
    lastTime = currentTime;

    if(delta >= 1){
    update();
    drawToTempScreen();
    drawToScreen();/
    delta--; // -- = -1
    drawCount++; // ++ = +1
    }
    if(timer >= 1000000000){
    System.out.println("FPS: " + drawCount);
    drawCount = 0;
    timer = 0;
    }
    }
    }

  • @kikismine
    @kikismine 2 года назад +1

    @RyiSnow can you give me please your version of GamePanel.java for me the game is not working in half of the video please send me your verison!!!

  • @MrVeeju
    @MrVeeju 2 года назад +1

    Thank you RyiSnow for awesome videos! They have helped me so much to understand Java better. Looking forward to your following videos.
    My game became so slow when I changed it to full screen. It is because of the Java drivers and for me it helped when I added the following line to Main.java before window = new JFrame();
    System.setProperty("sun.java2d.d3d", "false");

    • @aliasgarjiwani6898
      @aliasgarjiwani6898 2 года назад

      i am having the same problem ,i tried your method and its same as it was i am using java 1.8