Collision Detection - Episode #09 - Platformer Tutorial Java

Поділитися
Вставка
  • Опубліковано 13 січ 2025

КОМЕНТАРІ • 67

  • @sametatac2715
    @sametatac2715 2 роки тому +7

    I love ur tutorials btw, clear enough

  • @gamrets4352
    @gamrets4352 2 роки тому +3

    Thank you very much for these wonderful tutorials. I watched many videos on how to create video games and the truth is that for now your tutorials are the best I've ever found. You explain very well how video games work. Good luck, surely your channel will grow and in a few years you will have many subs

    • @KaarinGaming
      @KaarinGaming  2 роки тому

      Cheers man!
      Appreciate the kind words :)

  • @brx5840
    @brx5840 Рік тому +1

    its just Wonderful, thak you so much for thes tutorials 😍😍

  • @MCchaosbrodog
    @MCchaosbrodog 11 місяців тому +1

    i love your videos

  • @LeonoX97
    @LeonoX97 Рік тому +1

    Amazing

  • @kairu_b
    @kairu_b 2 роки тому +1

    Awesome

  • @ЧИКЕНБУРГЕР-э8й
    @ЧИКЕНБУРГЕР-э8й Рік тому +1

    thank youu vary good lesson

  • @felipegomes2263
    @felipegomes2263 2 роки тому +3

    Question: the knowlege you have about Java, you learned searching around or was there a specific course you took?

    • @KaarinGaming
      @KaarinGaming  2 роки тому +4

      Utube, searching around and tutorials

  • @btsbloodsweatandtears4021
    @btsbloodsweatandtears4021 2 роки тому +12

    I hope this project can help me get an internship so thank you.

  • @felcy1458
    @felcy1458 7 місяців тому +3

    hey Kaarin, i've already compare my code with your code at github, but when I run my code the player doesn't move when I press the WASD keys. i hope you can help me to solve this problem. anw thank you for the tutorial, It help me to do my final project

    • @KaarinGaming
      @KaarinGaming  7 місяців тому +2

      Hey. Glad you like it. Its better to ask for help on discord. Most likely you missed a bracket or forgot to add a call to the playing state.

    • @felcy1458
      @felcy1458 7 місяців тому +1

      @@KaarinGaming greatt, thank you

    • @monikavarma757
      @monikavarma757 3 місяці тому +1

      @@felcy1458 hey there, what did you do?? i got the same problem...i checked my brackets too. i hope you reach me out soon. i'm doing it for my project too!

  • @andreicostache4646
    @andreicostache4646 Рік тому +1

    Hi ! Really nice tutorials ! At 25:47 why is did you put 20 as width and 28 as height ?

    • @KaarinGaming
      @KaarinGaming  Рік тому +1

      Hey.
      That is because the player is roughly 20x28 in size in the sprites. This will be the actual hitbox for the player, not the size of the entire sprite thats 64*40

    • @andreicostache4646
      @andreicostache4646 Рік тому +1

      @@KaarinGaming thank you a lot. That helped to calculate the hitbox for my character

  • @notsospecialised
    @notsospecialised 4 місяці тому +1

    absolute legend
    starting to get lost

  • @milicaradojnjic4313
    @milicaradojnjic4313 Рік тому +4

    When I use 1.5 scale it does not draw player in the hit box, but outside it. How to fix that?

    • @thesuperfluousone2537
      @thesuperfluousone2537 Рік тому +1

      I had the same problem. You may have to visit Player class, render() method, g.drawImage and incorporate Scale into the width and height. Kaarin may have done this offscreen.

  • @thesuperfluousone2537
    @thesuperfluousone2537 Рік тому +2

    My hitbox doesn't center on the player. Worse, it changes based on the scale of the game.
    Edit: Had apply SCALE when rendering player and had to correct x and y offsets.

  • @budijansen4773
    @budijansen4773 Рік тому +2

    Hi Kaarin, sorry for the late question. i want to ask about how you can scale player Sprite by just changing the SCALE variable inside Game.java . how can you do this? when i change SCALE value, my player sprite does not resize

    • @KaarinGaming
      @KaarinGaming  Рік тому +3

      Hey.
      You most likely forgot to add scale to your player. Github have all the code for you to compare.

    • @budijansen4773
      @budijansen4773 Рік тому +3

      wow thank you so much, I absolutely did not expect you to answer me directly right here@@KaarinGaming

  • @8NLD8
    @8NLD8 2 роки тому +2

    is this Separating Axis Theorem? (SAT) I've read that SAT is commonly known to be used to detect collision in games and i want to implement it, i've also read that it works by checking the axis of the hitbox so i wanna know if this is it because it seems like it, i've searched tutorials bout SAT but i havent found any :S

    • @KaarinGaming
      @KaarinGaming  2 роки тому +1

      I have no clue. Not heard of it before

  • @ciphervoid6697
    @ciphervoid6697 Рік тому +3

    Hello when did height and width get included in the entity class? It just popped out of nowhere

    • @KaarinGaming
      @KaarinGaming  Рік тому +1

      Hey.
      Mostly a recording miss. I restarted over and over again at so many places, and sometimes some parts where left out. But you will still be able to follow along regardless :)

  • @jonesandrew2839
    @jonesandrew2839 2 роки тому +2

    I’m a total beginner so this might be a stupid question, but if we’re always gonna have to cast float back into integer, what’s the point of making it float in the first place? And what’s the difference between float and double and why do you choose to use float and not double?

    • @KaarinGaming
      @KaarinGaming  2 роки тому +4

      Hey.
      There is a few reasons why we keep float and then turn it into int. From experience it's much easier to spot why, but let me give you an example:
      With int, we can at lowest speed, increase the player position by 1 pixel each update. That would be 200 pixels per second at 200 ups. That is VERY fast. However, if we have it with float, we can increase it as slow as we want. and then just go from float to int when we draw. Some updates will have the same int value, but the float value changes behind it to match the speed we want.
      Difference between float and double is the precision. Meaning a double can have more decimals than a float
      but also takes up more memory. So if we don't need to be so precise, no need to use double. When working with timing, we need to use double.

    • @jonesandrew2839
      @jonesandrew2839 2 роки тому +1

      Thank you for the explanation! I think I understand why now. Your videos are so helpful

  • @中文中国-t4u
    @中文中国-t4u Рік тому +1

    Please can anyone tell me why my player can’t be stay focused I mean the bug which u solved in previous episode in my code is not working no matter how to change it I did exactly what u did but still running outside frame when u click on board he continues his direction 😢

    • @中文中国-t4u
      @中文中国-t4u Рік тому +1

      I’m also following code from website so I checked many times all the related classes all are the same but the bug is still there

    • @中文中国-t4u
      @中文中国-t4u Рік тому +1

      In Game class one method with windowsFocusLost in Player class resetDirBoolean and set all directions to false then in GameWindow add jframe addFocusListener inside focus lost method call gamePanel.getGame().windowsFocusLost method

    • @中文中国-t4u
      @中文中国-t4u Рік тому +4

      Problem solved inside windowFocusListener I called FocusListener it should be new WindowFocusListener 😅

  • @tylerthefou5946
    @tylerthefou5946 Рік тому +1

    when did height and width were added in class entity?

  • @jmg9509
    @jmg9509 2 роки тому

    8:02 - Detect Collisions

  • @xianreellines6007
    @xianreellines6007 Рік тому +2

    I really love your tutorials, but I got to ask though how do I add more levels or do you have a tutorial on how to add new levels?

    • @KaarinGaming
      @KaarinGaming  Рік тому +2

      Cheers =)
      It gets addressed in a later episode. Last one covers it for example.

    • @xianreellines6007
      @xianreellines6007 Рік тому +1

      @@KaarinGaming Thank you so much!

  • @shreeharam
    @shreeharam Рік тому

    why isn't the position of sprite changing with the subtraction in offset. i thought we will repaint or render hit box on top of the sprite

  • @MrDummyKicker
    @MrDummyKicker 7 місяців тому

    im wondering why you chose java swing. I honestly think its powerful enough til you get to using shaders and more advanced collision

  • @scopiomc
    @scopiomc Рік тому +1

    I only can move left or right so if i press w The player is goind left and when i press s hes movig right

    • @scopiomc
      @scopiomc Рік тому

      And when i press a and w or s and d together the player is entering god mode and is so fast

  • @gug4l
    @gug4l 2 роки тому +1

    Hey. Great Job! Thank You dir your Work! I've decided to build level in level editor. So I have whole lvl in 1 PNG 1:1. What should be my approach regarding collision detection? Should I change it?

    • @KaarinGaming
      @KaarinGaming  2 роки тому

      Thanks for the kind words =)
      We cover how to add more levels and also how you as followers can add and make your own levels in a later episode.
      No need to change the code for collision because the level changed.

  • @unknownknown278
    @unknownknown278 2 роки тому +1

    Hi kaarin, Great project and thank you sharing it. I've done so far what you did in the video, but after compilation it says "out of bounds", what should I do?...

    • @KaarinGaming
      @KaarinGaming  2 роки тому

      Hey!
      Sounds like you have an array that tries to access something that is outside the lenght of the array. Take a look at the error and it will tell you where the error occour.
      There is github to compare your code to

    • @unknownknown278
      @unknownknown278 2 роки тому +1

      @@KaarinGaming Yeah, thank you a lot😊

  • @Artkoch228
    @Artkoch228 2 роки тому

    16:57

  • @ciutoivoi
    @ciutoivoi 2 роки тому

    I think it can't work with dynamic map

  • @droidlycodes
    @droidlycodes 2 роки тому +2

    50th like so please enlighten my brain... Collision works great buttttt, when I spawn in monsters in my game at random locations sometimes they spawn over another monster causing it to get stuck. I swear I have spent multiple hours trying different ideas with my auto spawn system but nodddda luck 🙃

    • @droidlycodes
      @droidlycodes 2 роки тому

      Here's my logic, by default monster collision false in draw method. Then monster checks monster array to see if intersects also is supposed to check if not monster equals monster but it doesn't appear that is the case. It just bypasses this call & sets collision to true when one monster overlaps another. My brain hurts tried even writing a new class with no animation & still no luck.

  • @l007thom6
    @l007thom6 2 роки тому

    Time step for me: 8:16

  • @eldernovaisss
    @eldernovaisss 2 роки тому

    for some reason my collision doesnt works:(

    • @KaarinGaming
      @KaarinGaming  2 роки тому

      Don't forget you got github/website with the code available and if that doesn't help, there is the discord server.

  • @diegomacias230
    @diegomacias230 2 роки тому +2

    first

  • @trompowsky12
    @trompowsky12 2 роки тому +2

    second

  • @hagenzareba9654
    @hagenzareba9654 2 роки тому +2

    third

  • @sametatac2715
    @sametatac2715 2 роки тому +1

    forth

  • @zixuan1630
    @zixuan1630 2 роки тому +1

    sixth