Important Bug Fix & Update - How to Make a 2D Game in Java

This video is about fixing bugs and improving our code.
There are some differences between new objects and referenced objects...
Thank you for pointing out these issues. You guys are making this program better than what I could make alone.
Timestamps:
0:00 Introduction
1:37 Fixing the First Bug
3:30 About the Merchant Item Bug
6:35 Creating a Static String on Each Object
7:40 Creating the EntityGenerator Class
11:30 Fixing the Merchant Item Bug
13:38 FINAL RESULT
#javagamedevelopment #javatutorial

Пікірлер: 51

  • @sorcerian_bootleg7112
    @sorcerian_bootleg7112 Жыл бұрын

    > Ryi: hello guys, i'm gonna do a short video this time, there's no new stuff, but please bear with me. > Also Ryi: *proceeds to do a 15 minute class about bug fixing and refactoring so our codes don't suck.* You're a gift from the heaven. Also this video showed me why equipment go sold out in games once you buy them a single time lol

  • @giorgioripani8469
    @giorgioripani8469 Жыл бұрын

    Thank you very much for the mention. You were very nice! I am having tons of fun refactoring classes and subclasses for NPC, Items, monter and projectile as abstract classes with abstract methods. Using the concrete classes to implement those methods, so that everything is no longer a general entity and I can control all of the stuff easier =D Looking forward to your next updates!!

  • @darkpaladin.
    @darkpaladin. Жыл бұрын

    Great video as always brother 👍

  • @tankietphan2043
    @tankietphan2043 Жыл бұрын

    So cool, hope you make more video about 2d game in java

  • @su4amp397
    @su4amp397 Жыл бұрын

    Hey Ryi! do you think about making a custscene system for the game in the future? I'm loving watching your videos, please don't stop! :D

  • @michajurkiewicz5471

    @michajurkiewicz5471

    Жыл бұрын

    I agree :)

  • @MajorMonogram

    @MajorMonogram

    Жыл бұрын

    Whats that?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    @Su4amp What kind of cutscene is in your mind?

  • @michajurkiewicz5471

    @michajurkiewicz5471

    Жыл бұрын

    @@RyiSnow I think a simple cust-scene like character A comes up to character B and says something.

  • @su4amp397

    @su4amp397

    Жыл бұрын

    @@RyiSnow like start the game and introduce a story and make it follow with some cutscenes as you play if it's not too much trouble to do, I would thank you forever because I've been trying to do this for ages hahaha,

  • @AngelloUI
    @AngelloUI Жыл бұрын

    This is amazing!

  • @ayamax-channel
    @ayamax-channel Жыл бұрын

    Hey Ryi! I start with saying that you're doing a wonderful job with your tutorial You're very clear but not slow or boring, it's very interesting watching all your videos and learning tons of things everytime!! :) I was wondering Will you add a sort of Ally NPC that helps you fight the monsters and follows you once you find him? Is it a very difficult or long thing to do? Or it can be done?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    NPC following the player was already explained in the pathfinding video (Part 40)!

  • @ayamax-channel

    @ayamax-channel

    Жыл бұрын

    @@RyiSnow Thanks for the answer! Yes I know, but for the NPC attacking monster while following player is something possible?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    @@ayamax-channel It is possible. We implemented a monster attack AI in Part 48 so try mixing the system then you can create an NPC who follows you and attack nearby monsters! Technically we've already covered what is needed. It's about what kind of AI pattern you want to add to the NPC (what kind of attack it does, the percentage, conditions, etc.)

  • @ayamax-channel

    @ayamax-channel

    Жыл бұрын

    @@RyiSnow ohhh I see. Thank you very much for the help and patience!

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Good luck!

  • @TORMENTUMM
    @TORMENTUMM9 ай бұрын

    Cool video again!

  • @romawar1869
    @romawar1869 Жыл бұрын

    thank you for good job

  • @dustinodett
    @dustinodett27 күн бұрын

    When I implemented the new eGenerator to the SaveLoad it kinda broke my game. My character would no longer load with the saved armor on and my storage would no longer work. In fact it would freeze the game and give and error about down1 being null. Other than that it all works fine. It also appears I do not "need" to remove all the "case" lines from the SaveLoad class so no biggie.

  • @gregoryfir3841
    @gregoryfir3841 Жыл бұрын

    Thanks for this video, Ryi! I have a question about bugs. What can be done so that after knockback, an entity (player or monster) does not get stuck in objects (for example, in a chest or door)?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    We've already handled that. Check your collision and make sure it checks all the solid objects.

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Sorry, I just realized I didn't add the direction modification if statement to the checkObject method. I probably assumed knockback doesn't affect objects but it does as you mentioned. So you're right and I apologize for the misunderstanding and my misleading response. Anyways, if you haven't fixed it by yourself, add the following if statement at the start of the checkObject method (just like we did for other methods) then the knockback collision will be handled properly. String direction = entity.direction; if(entity.knockBack == true) { direction = entity.knockBackDirection; }

  • @glowiak3430
    @glowiak3430 Жыл бұрын

    8:45 An easier way would be to have a public Object clone() { return new (); } inside. It's less time consuming.

  • @kamisama1712
    @kamisama1712 Жыл бұрын

    for some reason my saving and loading is messed up now. when i start a new game and save and then load the map objects dont change. but if i start from load game and save then when i load the next time the map objects are gone as they should be.. anyone else run into this issue?

  • @havardelgsaas2603

    @havardelgsaas2603

    Жыл бұрын

    the problem for me was I wrote name= "objName" in OBJ_Axe instead of name = objName. You must remove the two ", and it should work.

  • @Mrtargi
    @Mrtargi Жыл бұрын

    Hello Ryi! Also I think that it is better to add player location for the save method. It' s really strange to start from the same place if you have 10 levels for ex. Also I think that projectiles need collision with a solid tiles, as well as others)

  • @Mrtargi

    @Mrtargi

    Жыл бұрын

    Also, it is not bug, but if you do not save the status of interactive tiles, they'll appear again and again, so if you have something like crates it creates infinite farm options))

  • @Ramej
    @Ramej Жыл бұрын

    can i suggest on how to do cutscenes? like for the lore/story of the game 😁 much appreciated

  • @michajurkiewicz5471
    @michajurkiewicz5471 Жыл бұрын

    Ryi, you run the best java channel for programming games in java. I hope your channel grows because you deserve it like no one else :) Please think about making cutscenes, quests and a simple selection of classes and dialogue options. Then, thanks to your videos, you will be able to make a powerful game :) I know that it will extend the series, but believe me, the longer the better :)

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    I'm not sure if the longer the better. When you add new features, usually you review the entire code and rebuild it from the ground up if necessary to make the code clean and more organized. That's what I would do if this was my private project. But I find it difficult to do so in this kind of public (and long) series because there are already many people who watched your videos and created their code based on what you have uploaded before. I personally feel saying "OK, I want to add this new feature but it's not compatible with the current code so let's scratch the current one and start from the beginning" is not a nice thing to do. So I've been doing my best to incorporate features that I didn't set in my original roadmap, in a way that doesn't require too much reconstruction yet somehow fits the existing code decently. Sometimes it takes several days to come up with an idea. It's not as easy as you might think... The current code is working fine but I have to say it is already pretty much patchworked and I'm not a big fan of how it looks. The longer the series goes, the more this kind of compatibility issue becomes unavoidable and I feel like I've already come almost as far as I could without rebuilding the base code. If I make the current game from the beginning, I will take a different approach and the fact stresses me out. I will keep thinking of ways to implement it whenever I get a request but also hope you understand that adding features that you didn't plan when you created the base code is not always so easy. Anyways, thank you for your comment, and I am glad that you're still enjoying the series.

  • @michajurkiewicz5471

    @michajurkiewicz5471

    Жыл бұрын

    @@RyiSnow Thank you for such a long and comprehensive answer :) As for the series, it's great. You are a great teacher :) When it comes to modifying the code, it is unfortunately unavoidable with large projects. You already have quite a large community, and I think you can ask us for an opinion on how you will do the next series. As for me, I would like custscenes, a boss fight and quests and believe me, I will not bother you anymore: D PS Think about patronite, I think your effort should be rewarded, because I can see how much effort you put into it :)

  • @wizco4443
    @wizco4443 Жыл бұрын

    Hey @RyiSnow, I am way earlier in the series (Just completed first half), anyways I just noticed that when I hit a solid tile in the up, down and left direction the collision works fine but when I hit a solid tile on my right I need to go up or down to get out of collision because when I press A or left the animation plays but my character doesn't move, I have spent all of the past two days trying to figure this out but I can't for the life of me find out what I did wrong. I posted another comment like this on the collision video but just in case you don't check those comments anymore I have posted it here. ANNY HELP OR SUDGESTIONS ARE WELLCOME!!!! This doesn't completely hinder my progress but it makes it difficult to play.

  • @lordkoffin1099
    @lordkoffin1099 Жыл бұрын

    Your voice is very cute ♥️♥️

  • @chrisfeasby7528
    @chrisfeasby75286 ай бұрын

    Is there an easy way to check if the item being sold is already in one of the players inventories?

  • @RyiSnow

    @RyiSnow

    6 ай бұрын

    You can scan your inventory and check if you have an item that has the same objName!

  • @chrisfeasby7528

    @chrisfeasby7528

    6 ай бұрын

    @@RyiSnow thanks next time I’m coding I’ll try that!

  • @chrisfeasby7528

    @chrisfeasby7528

    6 ай бұрын

    @@RyiSnow when I scan the inventory .objName is not visible .. do you suppose using just the name is okay? It’s giving me some issues though.

  • @markmcneill9566
    @markmcneill9566 Жыл бұрын

    Truly the best java game

  • @lschulz1914
    @lschulz1914 Жыл бұрын

    Hi RyiSnow! i love your videos :) I am fairly new to Java and 2D Games and have a question. Could you show how to use a spritesheet instead of single files ?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    I can't explain step by step here but you can use the getSubimage method in BufferedImage class and put the images in an array. That said, that's not something we're doing in this series so as the series goes you'll need to arrange some parts of the code by yourself. If you are new to Java and the method that I just mentioned still doesn't make sense, importing the images one by one like in the video might be easier.

  • @lschulz1914

    @lschulz1914

    Жыл бұрын

    @@RyiSnow Thank you for you answer! i will look into it and continue with single files for now :) i hope you will continue with this series, it is really fun and you are an excellent teacher !

  • @MrLoser-ks2xn
    @MrLoser-ks2xn6 ай бұрын

    🥰🥰🥰

  • @n10.phaminhthanh89
    @n10.phaminhthanh89 Жыл бұрын

    game bomberman ,plz !!!

  • @anonymus_the_real
    @anonymus_the_real Жыл бұрын

    Hi what is your discord name and #?

  • @Wexysad
    @Wexysad Жыл бұрын

    Hi Ryi. First of all, I love your videos, you explain really well and I think I can learn coding thank to you. Now Im at the part 9 but I am getting an error, I try to fix it but I cant understand it. Can you gimme your discord or gmail to show you my error

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    If you could zip your project folder and send it via email then I will take a look. Please add a description of your issue. The address is in the about section.

  • @Wexysad

    @Wexysad

    Жыл бұрын

    @@RyiSnow Thanks but when i changed one small thing the error got fixed. İf i get an error next time i can send it to you