Object Detection/Loot - How to Make a 2D Game in Java #42

In this video, we implement a function to detect nearby objects so we can use a key and open a door. Also, we place a treasure chest and put a loot in it!
If you want to use my assets (images/maps/sound) that are used in this tutorial, here's the link:
drive.google.com/drive/folder...
Guidelines for using Blue Boy Adventure's code and assets:
docs.google.com/document/d/1q...

Пікірлер: 30

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

    Bug Fix: I've noticed there are situations where the key doesn't work. I realized the calculation col = nextWorldX/gp.tileSize doesn't round the result value (for example 13.997 is still counted as 13) so sometimes you get a col number that is not where the door is. Here's the fix: (getDetected) switch(user.direction) { case "up": nextWorldY = user.getTopY()-user.speed; break; // change 1 to user.speed case "down": nextWorldY = user.getBottomY()+user.speed; break; // change 1 to user.speed case "left": nextWorldX = user.getLeftX()-user.speed; break; // change 1 to user.speed case "right": nextWorldX = user.getRightX()+user.speed; break; // change 1 to user.speed

  • @tothpeter2296
    @tothpeter22969 ай бұрын

    My dialogue when Blue Boi consumes a "Key" "Are you trying to eat the Key?! You donkey!" Just a slight play with words (eating is a derivative of consuming)

  • @Langostaz
    @Langostaz2 жыл бұрын

    Awesome! thanks for releasing great content!

  • @dustinodett
    @dustinodettАй бұрын

    @ryiSnow I am so excited!!!!! I have learned so much from you! I took what we did with the merchant npc and made a storage chest out of that code! It took me all day to work out the problems I kept facing but I succeeded! Thank you!

  • @gregoryfir3841
    @gregoryfir38412 жыл бұрын

    Thank you, RyiSnow! It's amazing video! Please, could you explain how to do critical damage for weapons, if you have the time and desire. I tried to do this, but it turned out that the weapon just got a random attack value for the whole game. Thanks again

  • @RyiSnow

    @RyiSnow

    2 жыл бұрын

    You can set a percentage for critical hits (and a critical damage too if you want) on each weapon like this: [Entity] public int criticalRate; [Weapon] criticalRate = 8; Then when you give damage to a monster, use the Random class and get a number between 1 to 100. If the number is within the current weapon's criticalRate (1 to 8), double the damage or add an extra number.

  • @Nick-ns3vj
    @Nick-ns3vj2 жыл бұрын

    can you make a tutorial on how to make lighting (for example from a lightbulb: A small lightened area)? And also, about how to make the game's lighting darker in general, like in a horror game. Or just at night - How to make the screen go dark xD. Cause I wanna implement a lantern item in a ruin, and I need to know how lighting works

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Жыл бұрын

    Thanks!

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

    Hi RyiSnow! I noticed in later videos that in the OBJ_Chest class, you have a method written called setLoot, in which video did you write this method because I've looked at the later videos and couldn't find where exactly it was written. I'd like to know where we call this method and how to pass the loot through the method. Thanks!

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    I did it when I implemented the save and load system!

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

    There is a bug in this one. If you place some coins, or pick them up when you kill a monster, you get an error. It is because under player/pickUpObject, it is nulling out type_pickupOnly items BEFORE it then looks to see if its an obstacle or inventory. Need to add an if loop around the code after the pickup to check if the gp.obj[gp.currentMap][i] != null to avoid it. Hopefully he fixed it later.

  • @momagi6039
    @momagi60392 жыл бұрын

    Nice!

  • @vitocabrito123
    @vitocabrito1232 жыл бұрын

    Nice

  • @hamzaa7335
    @hamzaa73352 жыл бұрын

    nice tutorial bro, but where you have this knowledge?

  • @vitocabrito123
    @vitocabrito1232 жыл бұрын

    how long have you been programming games?

  • @RyiSnow

    @RyiSnow

    2 жыл бұрын

    I wrote my first Hello World program about 6 years ago.

  • @vitocabrito123

    @vitocabrito123

    2 жыл бұрын

    @@RyiSnow thank you very much for the reply, hugs from Brazil

  • @UnderArea51
    @UnderArea512 жыл бұрын

    IDEA: Who is be possible to add a bit of code to give our player's hero a NPC who follows with him around? - Perhaps a pet wolf or hawk. It would be great if the wolf could attack monsters - automatically when they get near the hero.

  • @RyiSnow

    @RyiSnow

    2 жыл бұрын

    Check the Part 40. We implemented an NPC who follows the player and monsters who attack the player when they detected him. Combined with them you can create an NPC who follows the player and attacks monsters nearby.

  • @bluethemcguy4430
    @bluethemcguy44302 жыл бұрын

    Hi RyiSnow, if possible could you give me a thought on how to implement infinite world generation? I really want to implement this in my game.

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

    🥰🥰🥰

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

    Hi, i have an issue. If I add boots and it speeds up my character and then try to open the door, it just cannot be done because the col or row does not match. Currently default speed is 4 and with the boot is 5.Do you know how to fix it?

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

    Hey @RyiSnow! At this point I just noticed my generate particle doesn't work anymore for cutting down trees and I had to try to make it work when we changed the list to [][] array for the projectileList.add(p1) ... projectileList.add(p4) etc ... I made it work for the destroying of the enemies rocks but the trees do not get damaged anymore ... can you or someone else Please post the code for Entity's generateParticle(Entity generator, Entity target) Up to this point in the series so I can see the fix for that method when everything was changed to double array [][] (This method you must of fixed on own as it was not shown in the video at the time nor since) Appreciate it greatly if you could post that! Thanks! And as always LOVE the tutorials!! :)

  • @RyiSnow

    @RyiSnow

    6 ай бұрын

    Hi, I didn't change the generateParticle method. It's the same as I showed in the particle video.

  • @chrisfeasby7528

    @chrisfeasby7528

    6 ай бұрын

    But you changed ArrayListprojectileList to Entity[][] projectile .. Now in that generateParticle method in Entity we have to change it otherwise there would of been errors? It used to be gp.projectileList.add(p1)… to .add(p4) Can you double check your Entity generateParticle() to see

  • @RyiSnow

    @RyiSnow

    6 ай бұрын

    I changed the projectile list to two-dimensional but kept particleList one-dimensional since particles just disappear and we don't need to keep them on the map. Maybe you changed the particleList to two-dimensional by mistake? And yes, I double-checked my latest generateParticle method and the method I showed in the particle video and they were identical.

  • @chrisfeasby7528

    @chrisfeasby7528

    6 ай бұрын

    @@RyiSnow it doesn’t appear like it? The particle list is not two dimensional.. I’m not sure what happened but I guess it doesn’t matter. I’ll redo your tutorial for further experience after I do the rest of your you tube tutorials on Java as you are very good. Having a GitHub account would help matters greatly but I understand this world is full of thieves who steal and release as their own. I hope you continue to make KZread tutorials- I’ll definitely be watching!! 🙂

  • @GageAOlson
    @GageAOlson2 жыл бұрын

    Do you have a discord?