Collision Detection - Episode #09 - Platformer Tutorial Java

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

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

  • @sametatac2715
    @sametatac2715 2 года назад +7

    I love ur tutorials btw, clear enough

  • @gamrets4352
    @gamrets4352 Год назад +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  Год назад

      Cheers man!
      Appreciate the kind words :)

  • @brx5840
    @brx5840 11 месяцев назад +1

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

  • @felcy1458
    @felcy1458 4 месяца назад +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  4 месяца назад +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 4 месяца назад +1

      @@KaarinGaming greatt, thank you

    • @monikavarma757
      @monikavarma757 15 дней назад

      @@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!

  • @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 года назад +3

      Utube, searching around and tutorials

  • @notsospecialised
    @notsospecialised Месяц назад +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 9 месяцев назад +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.

  • @budijansen4773
    @budijansen4773 11 месяцев назад +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  11 месяцев назад +2

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

    • @budijansen4773
      @budijansen4773 11 месяцев назад +2

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

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

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

  • @8NLD8
    @8NLD8 Год назад +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  Год назад +1

      I have no clue. Not heard of it before

  • @ciphervoid6697
    @ciphervoid6697 Год назад +2

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

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

      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

  • @MCchaosbrodog
    @MCchaosbrodog 8 месяцев назад +1

    i love your videos

  • @andreicostache4646
    @andreicostache4646 Год назад +1

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

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

      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

  • @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 9 месяцев назад

    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

  • @ЧИКЕНБУРГЕР-э8й
    @ЧИКЕНБУРГЕР-э8й Год назад +1

    thank youu vary good lesson

  • @中文中国-t4u
    @中文中国-t4u 9 месяцев назад +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 9 месяцев назад +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 9 месяцев назад +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 9 месяцев назад +3

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

  • @kairu_b
    @kairu_b Год назад +1

    Awesome

  • @LeonoX97
    @LeonoX97 Год назад +1

    Amazing

  • @tylerthefou5946
    @tylerthefou5946 Год назад +1

    when did height and width were added in class entity?

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

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

  • @thesuperfluousone2537
    @thesuperfluousone2537 9 месяцев назад +1

    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.

  • @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.

  • @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.

  • @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

  • @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😊

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

    I think it can't work with dynamic map

  • @novaisss9161
    @novaisss9161 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.

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

    8:02 - Detect Collisions

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

    Time step for me: 8:16

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

    16:57

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

    second

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

    third

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

    forth

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

    first

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

    sixth