Title Screen (+Extra) - How to Make a 2D Game in Java #17

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

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

  • @kevincolgan6651
    @kevincolgan6651 2 года назад +14

    Your the first person to actually create a full game in java on you tube. thanks for this!

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

    Seeing a new video of this series makes me happy! Thanks so much for your work!

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

      You're welcome!

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

    Hey RyiSnow,
    Your channel and tutorials have been a great help for me to learn java. Thank you very much for your kind efforts.
    I have also edited the Title Screen a bit where instead of displaying the player image, i show the player moving from left to right until it hits the screen. I am further going to edit it more to make it more catchy and beautiful, but all of this has only been possible because of your tutorials. Thank you very much!!

  • @Gnarkson
    @Gnarkson 2 года назад +9

    Your channel is just amazing!
    Please, proceed with your work!

  • @moinofriend_yt1430
    @moinofriend_yt1430 7 месяцев назад +1

    Youre a legend!

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

    Thank you so much for this series, I've had a lot of fun with this the last few days.

  • @nadinewalter-lang9333
    @nadinewalter-lang9333 5 месяцев назад +1

    Your tutorials need more attention!

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

    Best tuts I've seen on youtube in years! I've encountered a fairly inconsequential UI bug... when I'm in Character Select and go Back to Title screen the small > (greater than) sign we use to highlight menu items doesn't appear until you press S or W again. I'm sure if I put some thought into it I could figure it out, and I'm sure I wrote this bug myself somewhere and it's not your fault at all. I had to fix a few Null pointer exceptions throughout this video which taught me a lot too.

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

      It's not your fault that the UI was bugged, that's how it was programmed. If you set gp.ui.commandNum = 0; when you hit the back button then it goes back automatically.

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

    I often forget to like the videos. But for your videos I try to like them again and again after forgetting I already did.
    You're doing a great job, keep going :)

  • @adnan2734
    @adnan2734 Год назад +3

    These tutorials are incredible!

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

    First of all, thank you for making this series RyiSnow, I cannot express how much it has helped me!
    I have a question in regard to audio. I'd like for the title screen to have it's own audio and then go to the play audio when the player gets past the title screen. The problem is that the audio from the title screen continues to play after the player gets to the play screen. Then, both the title screen music and play music play at the same time. Almost like the music.stop() method is not working. I even set it to stop the music when the player hits pause, but nothing. Could you check to see if it is an error on my end? For reference, I called the music methods in the KeyHandler class. Also, if i call the music.stop() method right after music.play() method it works, but obviously the music never gets played because it was stopped right after it was started.

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

      You need to call the stopMusic() before calling the playMusic(index). I tested in my environment and it worked fine. When I pressed the start button, the title screen music stopped and the play music started.

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

      @@RyiSnow It works, thank you!

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

    Tip: add gamePanel.stopMusic(); to the back button on character selection screen. As to avoid multiple instances of music starting and playing over each other.

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

    tis times eps was so easy to understand especially te keyhandler part

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

    Hi, I have one question, its possible to do all about map, npcs with your method and screens like title screen or another screen with JavaFX in a .xml, I was working with that for a problem and I don't know how to merge all. Thank you so much for this content!

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

    Hi RyiSnow, love the videos, thank you
    I wanted to add to my main menu a video on the background, representing the game, makes it feel better than just a simple color, but it seems I can't find a way to implement that, is there any way you could help me with that?
    Thank you!

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

    One question, all the extra modifications in the following movies they are kept thank you very much !

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

    Omg, thank you so much Ryi, u helped me a lot!

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

      Glad to hear that!

  • @Mypremiumacct
    @Mypremiumacct 4 месяца назад

    Is there a reason you copy and paste things into the } as opposed to just move the }? other than that great vid! I just have been deleting the bracket and placing it where it should go, thugh I can see it would be different when moving it to a totally different place

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

    can anyone help me, i dunno why this happened, but my keyHandler seems kinda a bit bug. "W" and "S" button for title screen works totally fine, but the "Enter" button didnt work at all. And also when i change to playState, all of the button didnt work at all, so the character just stands there, anyone have idea?

  • @ParalyticAngel
    @ParalyticAngel 7 месяцев назад

    Dude, you are amazing.^^ Your series was really helpful so far and there are a lot of vids to go.^^ I guess when we are trough with it, we are selling AAA-Games like no other.^^ 🤣🤣🤣🤣🤣

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

    Thanks for everything!

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

    Any idea on how to stop the music and play another from the Array?
    Cheers!

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

    How could I put a type of scrollbar if the number of options exceeds a limit?

  • @protagonist_.
    @protagonist_. 2 года назад +2

    Hello Ryisnow, I have a question. I just added this titleScreen, but now when i start game my movement doesn’t work

    • @ThomasAgner
      @ThomasAgner 9 месяцев назад

      I have the same problem, did you solve it?

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

    Thank you for sharing your knowledge , i have a question is possible to add multi player option to online play 👍.

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

      I think it's possible if you have enough server knowledge!

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

    Those videos are literally my brain savior, thank you so much.
    But, maybe its in the next episodes (forgive me if it is).
    Is there any chance there is or will you do a tutorial how to interact with NPC's without needing to move? In the dialogue episode you thought in an amazing way how to program the system, but to interact with NPC I consistently need to move.
    Is there any option to interact without the need to move?

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

      Yeah, that was a bit inconvenient so I fixed it in Part 23. No need to press directional keys to talk to him!

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

    i know this is old, but is there a way to create a button that you can click, JButton i think, for the menu instead?
    and another container/panel for that buttons.

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

    A question!
    How can I change the Fonts to be different from the Title Name and the Menu?
    Thanks for all your videos!
    I've been learning a lot and I'll try to keep understanding everything about this.
    I would love to make my first game on Java, then maybe I'll explore other languages.
    THANKS AGAIN FOR EVERYTHING!

    • @RyiSnow
      @RyiSnow  10 месяцев назад +1

      You can set a font on g2 by typing: g2.setFont(fontname). Check Part 16 video for the details!

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

    I have a subscreen of the title that changes the language, a variable called language that defaults to English and also where there are texts that are printed on the screen, I have a conditional for example:
    if(gp.language == "english) {
    name = "Key;
    } else if( gp.language == "portuguese" {
    ...
    }
    however when I click on new game the texts do not change, they remain in English, how do I change the language?

    • @hillclimbracingcenter
      @hillclimbracingcenter 7 месяцев назад

      save the data in a separate file, as shown in episode 36 or 50

  • @ThomasAgner
    @ThomasAgner 9 месяцев назад +1

    I can't move my character after adding the class selection screen

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

    I played a different music in the title screen state and wanted to play a different music in play state, but somehow i can't make use of the stopMusic function to stop titlescreen music from being played during game state, so i currently have both music playing concurrently in playstate
    any help? :d

  • @havardelgsaas2603
    @havardelgsaas2603 Год назад +6

    If you want to play music in the title screen that doesn't overlap with the game music, you can write gp.stopMusic() and then gp.playMusic(something else than the music used in the title screen):
    if(code == KeyEvent.VK_ENTER){
    if(gp.ui.commandNum == 0){
    gp.gameState = gp.playState;
    gp.stopMusic();
    gp.playMusic(0);
    }
    if(gp.ui.commandNum == 1){
    //add later
    }
    if(gp.ui.commandNum == 2){
    System.exit(0);
    }
    }

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

      lol thanks bro i was wondering

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

      btw guys u should change playMusic in gamepanel and put the song u want on te menu

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

    Hi RyiSnow! I wonder how to create another character to play. Could you suggest a way to do that? Thanks

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

    I have a question sir, following your code, the getplayerimage method starts at the very beginning. How can I change the appearance of the character in character selection if the getplayerimage method run so early before character select?

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

      I already use if else statement in the getplayerimage method and made variable name character = 0 in the keyhandler so when the user choose character, the character variable value will be changed into 0, 1, 2, 3 then following the if else statement in getplayerimage method. But the problem is the getplayerimage method runs at the beginning before titlescreen or character select screen.

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

    Very nice

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

    i need help with the game menu, everytime i press enter it wont work and i cant fix it can you help?

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

    Nice ! I love your video.

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

    For some reason my cursor doesn't disappear after moving down, If I move down there is a cursor on all three lines and I have no idea how to fix it. Any help would be greatly appreciated.

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

    Thanks!

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

    Can i ask if you will implement the Restart function next?

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

      We will handle that when we implement a game over screen.

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

    Hello, ive really enjoyed your tutorials, right now im trying to add a side panel to the game where player information is displayed, can anyone tell me how to do this?

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

    🥰🥰🥰

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

    Will you go over crafting and building?

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

    How could we display a tile image (like grass01 or water01) as the background of the title screen instead if a color ?

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

      You can use the drawImage method!

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

      @@RyiSnow thank you so much!

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

    Any one no how i would implement a charachter selection screen that upon enter the game brings a different character

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

    Good afternoon. There is a question about the start menu, after clicking on a new game, I wanted to make a class selection. Created several more types in the entity class, such as warrior, mage and thief. Accordingly, when selecting the magician class in the menu, I would like to assign the type of magician to the player and, depending on the choice, load the default settings of the player corresponding to his class. But the problem is that when the game starts, the default values are already loaded and they cannot be changed : ( Tell me an option to change the default settings of the player. And yes, sorry for my English :D

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

      There are a number of ways to do that. You can prepare multiple default values and call them based on the class that you have selected.

    • @dustinodett
      @dustinodett 7 месяцев назад

      @@RyiSnow I have tried everything I can think of to do this. I have created seperate player classes, created seperate methods, used the commandNum we set in keyhandler class and no matter what I change I cannot get the seperate classes to draw to the screen. They are there, they have collision and I can move them I just can't see them. Any help would be appreciated. And yes after two years I am still learning from these videos!!!!

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

    How could I put a background image on the title screen instead of the color?

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

      You can draw images with g2.drawImage

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

      @@RyiSnow Is this the best way or is there a better way?
      BufferedImage Image;
      try {
      image = ImageIO.read(getClass().getResourceAsStream("/tiles/water03.png"));
      g2.drawImage(image, 0, 0, gp.screenWidth, gp.screenHeight, null);
      } catch(IOException e) {
      e.printStackTrace();
      }

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

      Don't import the image inside of the game loop otherwise, it imports the image 60 times per second and that is a waste of resources. I would prepare the image in the constructor or a method that is processed before the game thread starts.

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

      @@RyiSnow I imported the image in the drawTitleScreen method

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

    Hello i find a problem with ur tutorial, so basically i have implement the stop edge camera for the player. But if my player is at the edge and there is a npc there, the npc will move according to our opposite move because of
    int screenX = worldX - gp.player.worldX + gp.player.screenX;
    int screenY = worldY - gp.player.worldY + gp.player.screenY;
    can you help me to solve this problem ?
    Thank you

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

      Thanks for the report. I just posted the fix in community tab so pls take a look!
      ruclips.net/user/RyiSnowcommunity

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

      Okeee ty for ur hard work i will try it now. Thank you

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

    hello, i found that this game worked very well when downloading as a jar and sending it to friends until i added a title screen and the other intro screens, do you know why?
    the key functions work, except that it doesn't register on the game screen until i minimize then maximize the screen again. For example, if I click enter to get to the next screen, it "works" but doesn't show up until i minimize then maximize.
    Also, my player is gone entirely and I cannot move.
    Here are things that I can think of that I did differently from you if your exported jar works fine:
    Added a few extra objects
    Added randomized order for dialogue
    Added 3 intro screens including images and text
    I tried commenting out things that I thought might have impacted it, like extra images i put in the intro screens, the title screen entirely, and it still didn't work. Any idea why it doesn't work if I export it to a jar?

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

      the last time i exported it was before the npcs i think, if that helps.

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

      I see. Yeah sometimes what worked on IDE doesn't work when exported as a Jar. I have experienced a similar thing before. By the way, does the Jar still work in your environment?

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

      @@RyiSnow i am not sure what that means, i'm assuming you mean when i click the play button in my ide, in which case yes it does work. also i use intellij if that helps!

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

      No I mean, when you click the jar file (without using IDE), can you still play the game normally?

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

      @@RyiSnow no, if i open the jar i downloaded it does not work, sorry if that is not what you mean

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

    do we have to add the character class screen to implement future functions like projectiles and sword? or is it just a complete sample just to get us thinking

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

      It's just a sample so you don't really need to add that part if it's not necessary for you.

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

    May i have your source code? please

  • @orionmont-dragon5844
    @orionmont-dragon5844 9 месяцев назад

    Sorry every body, but i got a issue. The little ">" in the title menu do not work, but it work if I change the size of my window. Like I need to press w and go in full screen and then thw little ">" change is place 💁‍♂️...

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

    Solved my last problem... but now.... the problem is... on the extra screen, the letters on the last 3 lines look black. not white. problem!!! Solution??

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

    If anybody wants I made a simplified method for making already shadowed lines:
    public void drawShadowedLine(String text, int x, int y, int shadowWidth, int shadowHeight, Color textColor, Color shadowColor) {

    x += shadowWidth;
    y += shadowHeight;

    g2.setColor(shadowColor);
    g2.drawString(text, x, y);

    x -= shadowWidth;
    y -= shadowHeight;

    g2.setColor(textColor);
    g2.drawString(text, x, y);
    }
    //////////////////////////////////////////////

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

    I can’t pause the game for some reason now. I have it as gamesState = gp.pauseState;