Breaking Objects - How to Make a 2D Game in Java #32

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

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

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

    *NOTE*
    I added a line "setup(42, "trunk", true) at 15:05 but I did that just as a "we don't do this way" example, so make sure to delete the line (you'll get NullPointerException error if you keep the line).
    I've received a couple of messages from people who are getting errors because of this line and now I realized my direction was not clear enough so I apologize for that. Anyways, we handle the trunk image not as a Tile but as an InteractiveTile.

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

    The best Java game tutorials on youtube 👏👏👏

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

    one of the most essential videos in this playlist so far

  • @KaarinGaming
    @KaarinGaming 2 года назад +11

    The game have a nice oldschool feeling to it. Keep it up =)

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

      @Prabin I agree

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

      @Kaarin Gaming Thank you Kaarin! And yes I'm a very old school guy :P

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

      @@RyiSnow That's great man :)

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

    Thank you very much! You are offering overwhelming knowledge , in very simple words!

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

    Thank you for these videos Ryi! You are an amazing teacher! I hope you will continue this series for a long time

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

    Nice new video! THIS IS BEST SERIES ON YT!!!!

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

    Well done!

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

    Why not use Tile array we already have? Check if Axe hitbox intersects a tree tile and if it does, replace it with cut tree?
    All tile entities could get 'life' parameter that would decrease if you used a specific tool and tile would be replaced, if it reached 0.

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

    Thank you!!! This was one my favorite tutorials!!!

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

    Thank you Ryi. Perfect vid.

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

    Hello can I use projectile to clear the InteractiveTile not by axe or attack. Using fireball to burn the tree thanks

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

    None of the trees are appearing when I try it, the physics work like collisions but the images for the trees and trunk won't load.

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

    So what if i want to convert all trees to interactive trees how can i do this + i try to edit TileManager and check if tile map is 41 (Tree code on map) and make TileManager draw new InteractiveTile on each time he will have to draw tree, and it worked but with so much lag, can you make a video about this, please.

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

      I will do that if I make a sandbox game tutorial in the future!

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

      hey did you ever figure this out?

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

    Continue the great work!

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

    Hey, I just wanted to ask if there is any way to set a tile collision true only for NPC and not for player, so player can walk on the tile but the NPC cannot

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

      You just need to disable player's collision check. Then collision won't happen for player.

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

    If you want to have more img?
    You hit 1 time one img , 2 time one img . How to do it, I've been trying for a while now

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

      You can change the tile's buffered image based on its life value.

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

      @@RyiSnow so can i do, thanks

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

    Thanks bro.

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

    Awsome as ever!!!

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

    How can I set the monsters to chase the player, please help

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

      We'll handle that eventually.

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

    Would it be possible to basically carry on levelling up until exp is less than the required amount to level up? For instance, if I was on level 1, and I killed a monster for 100 Exp, and the required amount to level up was only 5. How would I make so it would keep on levelling me up until the exp is less than the required exp?

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

    Any github links ??

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

    Hey, having a bit of trouble - I made my breakable object tall grass which is 2 tiles tall and and 1 tile wide. It functions perfectly fine, the only problem is that whenever I move far enough down for it to be off screen, it disappears too early. I believe this is because once the top tile of it is off screen it becomes null, making the whole thing disappear. I've been trying everything to fix this but I can't seem to figure it out. Any ideas?

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

      Remember we increased the drawing range by a tile size in the part 5 episode so the black outline won't show up? Increasing the drawing range even more (by a tile size) should fix your issue.

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

      ​@RyiSnow Hi! I went back and tried doing this and discovered some very interesting things. After experimenting with the tile renderer, i found out that for whatever reason my interactive tiles seem to be completely disconnected the regular tiles rendering process. I even made the render window super small so I could see the black outlines again and the interactive tiles didn't bother disappearing when every other tile did. It seems they ONLY disappear when it goes off the window itself. I'm thinking this is more than likely something I messed up on my end but I don't really know where to look. Thank you for your help regardless!

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

      Did you change the range in the draw method of the InteractiveTile class?

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

      @@RyiSnow This was it! My problem was that I had not watched episode 33 yet where in which we override the draw method used in episode 32. Thank you so much for your help, them disappearing early was driving me insane and I couldn't figure it out at all.

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

    how do you make it so that when you cut a tree and after a certain time it respawns back? ive added apple trees and i want them to respawn after cutting in like 5 mins

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

      You can use a counter (60 frames = 1 second) or System.nanoTime() to check the time

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

      @@RyiSnow ooh thanks! youve actually answered a lot of my questions on twitter and youve really helped a lot, it always makes my day! but the only thing that wasnt solved until now was the monster damage msg wont show up above them

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

    Thank you for this awesome video!
    That was Definitely one of the extremely useful category!
    Ps. But what if it's the other way around and it's not predetermined tiles that you can change, but tiles that you want to change yourself, such as making your own path or placing your own barriers?
    If you want, it would be awesome if you could cover this topic as well. 🙂

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

    For some reason, there are some spots on my map that prevents me from cutting down the trees. I have tested them in other areas, and they work fine. I am also not getting any errors.
    Edit: It actually does work in those spots, apparently they stop working after cutting down two of them

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

    hey man idk if you worked with multiplayer support but there only few java game tutorials that show how to add multiplayer to the game but even they are super old 8 - 4 years ago. So i wondered if you could make a video on the multiplayer system it does have to for this series but maybe a another series with 4 to 5 videos. But still thanks for the amazing content

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

    Something that has bothered me for a while is that entities will display on top of tiles like the trees or walls. If we convert a tile with collision to an entity and add that to the entityList during the paintcomponent method in GamePanel, then they should render in front/behind entities.
    I'm trying to solve this on my own, but it's a little tricky. Would you be able to solve this problem in an extra video?

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

      hey did you ever figure this out?

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

    Thanks!

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

    Will there be a video on a map editor that converts the drawn map to a text file?

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

      I'd love to make one but there are still a lot of videos that I have to make before that!

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

      A little late but you can use Tiled, export as csv files, then read them into Java

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

    Hey I have a question, do you use multithreading in this project?

    • @Melvin-14
      @Melvin-14 2 года назад

      no he uses only 1 thread

  • @GustavoRodrigues-wz4om
    @GustavoRodrigues-wz4om 2 года назад

    is it possible to do this on Android Studio ?

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

      Not literally. You can use the concept and transfer it to Android if you have enough knowledge of Android though. Android uses different classes to handle graphics for example so the syntax will be quite different.

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

    Another idea what about making it possible to be full screen

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

      In the Main class just type
      window.setResizable(false);

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

      @@aarushkumar168 but does it scale well

    • @Melvin-14
      @Melvin-14 2 года назад

      @@aarushkumar168 that wont do anything

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

    So, I am working on my own project and I wanted to ask something.
    I have it to adapt to size of the screen (full-screen)
    I have class which handles that so it scales all values for rendering,
    but I have this problem, on large screens, the fps drops, whats weird is that fps counter still says its 60, but its surely lower,
    is there something I could do, other than making players reduce their resolution? Or making the game change resolution of screen by itself?

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

    How do you make it so a speed_potion has a 30 second timer?
    Thanks for the video keep it up!!!

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

      1 second means 60 frames so count 1800 frames!

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

      @@RyiSnow oh yeah that makes sense completely forgot to count frames

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

      Have we used frames to time something before?

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

    Hey, after this series is finished will you also make a video on how can we convert this game into .exe file :D

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

      Can't you just google it tho ?

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

      Actually, I've already made a video for that!
      ruclips.net/video/h68WlAn_Vfg/видео.html

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

    thank you bro to viedo

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

    nice work. I have done somthing like that :)

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

    Hey its always invincible.

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

    you should really learn how to name things according to the java naming convention
    most of your class and package names are poorly named

    • @Melvin-14
      @Melvin-14 2 года назад

      true but he is surely good at making games!

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

      I know this comment is old, but... "naming conventions" are GUIDELINES... not mandatory. That being said, if you work for a company, or are coding as a team, you should probably follow those guidelines. If you are the solo developer, you should feel free to do as you want. I am sure RyiSnow learned the guidelines and your comment is disrespectful. If you already know java so well... why are you here, learning from a tutorial on RUclips? And, yes... he is here, showing his code to others, using it to help other people, but, you should have a basic to moderate grasp on Java before doing these tutorials, so, you should be able to understand and change the code on your own, after the tutorials are complete... feel free to do that and make your own variable, class and package names. You should really not criticize others when your comment doesn't even use proper capitalization or punctuation... it's basic english, but you're worried about his code?

    • @Melvin-14
      @Melvin-14 2 года назад

      @@MorrowHopeMusic bro writed an intire paragraph about 1 sentance

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

      @@Melvin-14 Okay?, He explained the issues with your comment and it just happened to take up 1 paragraph no problems with that.

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

    Thanks for the videos!!! My trees lose damage when I walk on them is there something wrong with my code?
    public void damageInteractiveTile(int i) { // when damage is given to Tree or others
    if (i != 999 && gp.iTile[gp.currentMap][i].destructible == true
    && gp.iTile[gp.currentMap][i].isCorrectItem(this) == true
    && gp.iTile[gp.currentMap][i].invincible == false) {
    gp.iTile[gp.currentMap][i].playSE();
    gp.iTile[gp.currentMap][i].life--;
    gp.iTile[gp.currentMap][i].invincible = true;
    // GENERATES PARTICLE
    generateParticle(gp.iTile[gp.currentMap][i], gp.iTile[gp.currentMap][i]);
    if (gp.iTile[gp.currentMap][i].life == 0) {
    gp.iTile[gp.currentMap][i] = gp.iTile[gp.currentMap][i].getDestroyedForm();
    }
    }
    }