Advanced Combat - How to Make a 2D Game in Java #48

In this video, we create a monster who swings a weapon and implement its attack AI.
We also tweak our attacking method so each monster/weapon can have a different attack motion speed.
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...
Timestamps:
0:00 Introduction
1:00 Quick Update
1:35 Optimizing the Monster Class
12:57 Creating Orc Class
16:57 Fixing the Knockback Direction
26:05 Monster Swings a Weapon
28:26 Attack AI
36:09 Unique Attack Motion Speed
40:27 Conclusion
#javatutorial #javagamedevelopment

Пікірлер: 55

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

    *CORRECTION* At 25:00 I said we don't need to add the direction modification to the checkObject method but actually, we do. Without it, the player can get stuck in an object when he gets knocked back. So please handle the checkObject in the same way!

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

    hey man, just letting you know that I have learned so much from you! keep up the good work :)

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

    Interesting video, and nice implementation. Thanks for the tutorials

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

    @RyiSnow san this initial "prepare to attack" enemy state that gives the player the opportunity to dodge or attack first is so nice! Awesome lesson as always!

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Yeah, I wanted to implement a parry system so decided to add a different attack motion speed to each monster. I'm pretty happy about how it turned out.

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

    Hey Ryisnow, first of all thanks for a great tutorial on making 2D games and congratulations on your success on YT. Second, there was a problem when transverting the attacking() method from the player to the Character. To put it briefly, the character after attacking in any direction remains in a given attack position (for example, the character attacks the left side and stays there), and it is impossible to move, in the case of an enemy who also uses the attacking() method, he also stops, but sometimes completely throws him off the map. After that, no Errors are shown. In my opinion, this is the fault of the attacking() method, which maintains the attack state as much as possible. here is the method. public void attacking(){ spriteCounter++; if (spriteCounter motion1_duration && spriteCounter motion2_duration){ spriteNumber =1 ; spriteCounter=0; attacking= false; } } } I would be very grateful for any hints about the blend.

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

    I can't wait to play your final project for this guide! HECK I'D EVEN BUY IT!

  • @StepIntoTheNightmare

    @StepIntoTheNightmare

    Жыл бұрын

    Would you really or are you just saying that to give him false hope?

  • @misterdneh

    @misterdneh

    Жыл бұрын

    @@StepIntoTheNightmare heck no I want to see what he does with this, this has by far been the best guide of teaching what I think to be proper Java game development on the web so far! I sort of learned some stuff here and there in the past but Snow has tought me so much

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

    Damn man just when I thought you was finish, you always surprise us with more

  • @birbylikesfox1032

    @birbylikesfox1032

    Жыл бұрын

    true, this is the best channel for java game development yet! well detailed, consistent, up to date and all in all amazing :)

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    @Winston Yeah it's been long enough and was supposed to be finished at Part 50 but I guess I'll need a couple of more videos to reach the end :P My current estimate is that Part 52 will be the final episode :)

  • @darkpaladin.

    @darkpaladin.

    Жыл бұрын

    @@RyiSnow for me learning about artificial intelligence was the major kicker and you have given us enough knowledge that we could Optimize and create our own little sandbox projects

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

    Thank you so much for these videos!!!

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    You're welcome!

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

    Hopefully after this series you can create a 3D series. :)

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

    Interesting video, as always! This reminds me of my refactory classes xdd Now that player and monsters share pretty much all the attributes and methods i was wondering if it would be practical to add to your map editor a feature to place entities (monsters or npc's) on the map. Or objects. Also, maybe this is too far from the scope of the project, but i was wondering if you would explore jumping mechanics to reach higher places or fight aerial enemies. Thanks, and take care!

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

    Thanks!

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

    Thanks for the amazing video, RyiSnow! I very look forward to continuing) Can you please tell me how to make lightning/glowing objects like a torch in one of your videos? Or will it be another video?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Glad you liked it. That torch was handled as an entity, it's basically an NPC.

  • @karlpillay8360
    @karlpillay83606 ай бұрын

    Hey RyiSnow I'm not sure if you're planning on adding more to this series as you have completed the game but I was wondering if you could share a tutorial of a similar 2D game with a split screen function for a multi-player pvp mode

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

    Hi ryisnow! (My fave youtuber) was wondering if it was possible to tweak the code so its possible for the player to move whilst attacking? Thanks!

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

    NICE!

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

    Im lazy but please keep uploading these videos because I plan to stream them on Twitch from the start. Thanx! ❤️

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    That's interesting. Let me know when you do that!

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

    Hello Ryi! Thank's for that tutorial! How can I cancel the enemies attack animation? While it sees me it continuing attack again and again...

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

    So far, everything is great, but only the camera is not that great. Could you consider that reconstruct the camera part in this tutorial? Could you consider that add dynamic difficulties to this game, and automatically respawn monsters or re-generate others when they get destroyed or reset by timer?

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

    Soooo satisfying

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

    hey ryiSnow great video as always ! i do have an issue though after this video. When the orc starts swinging he never stops even when not in range so i think something is wrong. I looked through the video a bunch of times and I cant find whats different.

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

    Hello Ryi,i have problem in my code somewhere...when i press W to go up it does that perfectly but if i want to change direction i need to release W key to be able to move to side etc with D,if i am holding etc A i dont need to release A key and i can just simply press W while holding A and it will like override player movement and it will go to W direction while im holding it and when i release it will continue to go to A direction,why does this not work with W and S but it works with A and D?

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

    Great

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

    I have suggestions to make monsters that are bigger then 1 tile.

  • @jaytwist8738

    @jaytwist8738

    Жыл бұрын

    I second this, perhaps the final boss can take up more than a single tile?

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

    Can you do that the player can swim in the water ? and Nice toturial and thanks for them

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

    I appreciate your work, as I have done from Part 1. However, I have encountered another bug You can cut your own Fireball if you're quick enough... Plus, my Orc is always in aggro mode, ATK images don't show at all when it hits something (Player, for example), suffers from the same "displacement caused by the 2 tile design", and attacks while walking... I did everything just like you typed, that I'm certain about... It might be a semantic error somewhere...

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

    Hello, I wanted to ask a question that isn't really related to this video. I have noticed that for how the game works so far, if my pc is slow and can't keep 60 fps the whole game would go in slow motion: basically if an animation is fully shown in 60 frames, so in 1 second, if the game slows down to 30 fps, the animation takes 2 seconds to show. So it's like playing at slow motion, but I'd like to keep it so that if an animation last 1 second, it last 1 second no matter how many fps you have, even if it means speeding up the frames or cutting some. Is it something that is possible to implement/adjust in some "simple" way ? I have no idea how to start to fix it, but i feel it's something really important.

  • @misterdneh

    @misterdneh

    Жыл бұрын

    Technically running a game like this can always be set to 30fps, 60 fps isn't really necessary but some computers or devices can handle it fine others render 60fps by default not so well. In this case you would change the default player speed accordingly remember 30fps means for a smooth motion you could set your speed to 10 to move the player 10pixels every 1/3rd of a second. I too have played with this & studied it a bit further on the side because I am developing this for Android. I noticed lots of differences in some devices so I switched my max fps depending on the device specs & speed etc. Hope this opens your mind 😁

  • @hawkale140

    @hawkale140

    Жыл бұрын

    @@misterdneh It doesn't really fix the problem tho.. even with 30 fps, if there's some problem it would just " slow down" the game and not really lose frame how it should be.

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

    How to publish this? Like on Steam or play store

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

    Please add a link to monster Orc sprites. Also can we make the Green Slime monsters spawn at regular interval?

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Sorry, I forgot to upload them. Just added them to the drive. >can we make the Green Slime monsters spawn at regular interval? You can utilize a counter and let them spawn after a set amount of time.

  • @raghunaths5230

    @raghunaths5230

    Жыл бұрын

    @@RyiSnow Thank you very much sir, i am very much excited to follow your tutorial. i am learning many programming concepts like refactoring, optimizing code, debugging, new Java functions from your tutorial. This series increased my interest in programming because I am 'learning while playing'.

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

    Hi, just watched this video and i decided to start your series but i am getting some problems 1. When i move my player up or left, small black lines start to appear 2. Looks like my collision hitbox is a little bigger thats why sometimes i can't get in between trees

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Honestly, I have no idea about the cause of question 1 since I've never encountered such an issue. For question 2, check your player's solidAreas. If they are set as smaller than a tile size, you should be able to get through between trees. If you still cannot, I think something is wrong with your collision checking system. Also, if you have an issue on a specific subject, please post a comment on the related video. Then I know when the issue started and it's much easier for me to track down the cause. Thanks.

  • @coderz5734

    @coderz5734

    Жыл бұрын

    @@RyiSnow sorry but i thought you weren't active on those videos

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    No worries. I can't answer every question but I'm trying to be active as much as possible!

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

    I carry this part: "(Extra) Stopping Camera at Edge of Map - How to Make a 2D Game in Java" as long as possible. It failed in this part: Attack AI.

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    As I stated in those extra videos, those are "alternative ideas/routes" and are not necessarily compatible with the main route program. That's why I didn't give a number to them and named them "extra" instead. I emphasized this several times throughout the series but still, quite a few people seem to be misunderstanding this, I removed those extra videos from the playlist to prevent further confusion.

  • @wonderzhou662

    @wonderzhou662

    Жыл бұрын

    @@RyiSnow I think you misunderstood my thought because of my English skill. It is most likely II say it to myself. I watch your whole series I understand what is extra and you left a message under that video. Since I understand this game mechanics and better than before, I can carry the extra part until now.

  • @wonderzhou662

    @wonderzhou662

    5 ай бұрын

    @Robbirus2 Not really. Later on, you need to remove all that part in order to implement advanced algorithms for him original design.

  • @wonderzhou662

    @wonderzhou662

    5 ай бұрын

    @Robbirus2 Np

  • @wonderzhou662

    @wonderzhou662

    5 ай бұрын

    @Robbirus2 I didn’t continue to work on that project. I don’t have any idea of that.

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

    🥰🥰🥰

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

    Thanks!

  • @RyiSnow

    @RyiSnow

    Жыл бұрын

    Thank you so much for the support! I appreciate it.