How to Use Box2D Physics | Coding a 2D Game Engine in Java #48

Sdílet
Vložit
  • čas přidán 20. 05. 2024
  • Join the Discord: / discord
    In this episode I go over various improvements to our physics abstraction over Box2D. This involves creating a callback method for collisions and game objects on the component level. There are 4 events that you can recieve information about, including beginCollision, endCollision, preSolve, and postSolve. I also go over how to implement raycasting using Box2D, creating sensors using Box2D, and a few more physics abstractions. Lastly, I improve the editor a bit more from the last episode by adding multi-select object highlighting, and allowing the user to click and drag and only place one object in each grid square.
    Code: github.com/codingminecraft/Ma...
    0:00 Intro
    1:10 Highlighting Selected Game Objects
    5:00 Fixing Duplicated Objects when Click/Dragging
    11:39 Fixing Key Listener Bug
    13:10 Box2D Contact Listener
    15:51 Aside about Box2D User Data
    19:16 Box2D Contact Listener Callbacks
    25:08 Raycasting in Box2D
    31:54 Various Box2D Helper Functions
    37:05 Brief Note on Sensors
    37:30 Back to Business
    43:52 In the Next Episode
    ---------------------------------------------------------------------
    Website: ambrosiogabe.github.io/
    Github: github.com/ambrosiogabe
    Here are some books I recommend if you want to learn about game engine development more thoroughly. I do not profit off any of these sales, these are just some books that have helped me out :)
    My Recommended Game Engine Books:
    Game Engine Architecture: www.gameenginebook.com/
    Game Physics Cookbook (Read this before the next physics book): www.amazon.com/Game-Physics-C...
    Game Physics (Ian Millington): www.amazon.com/Game-Physics-E...
    Game Programming Patterns (Free): gameprogrammingpatterns.com/
    My Recommended Beginning Game Programming Books:
    JavaScript Game Design: www.apress.com/gp/book/978143...
    My Recommended Java Books:
    Data Structures/Algorithms: www.amazon.com/Data-Structure...
    LWJGL (Free, but I haven't read this thoroughly): lwjglgamedev.gitbooks.io/3d-g...

Komentáře • 9

  • @jonfisher4728
    @jonfisher4728 Před 2 lety +1

    Learned so much from these tutorials....thanks again Gabe.

  • @AROD-oh5ez
    @AROD-oh5ez Před 3 lety +5

    man i wish i was as good as you. i've made 3 games but i hit a ceiling everytime because i dont know how to do something and it's so frustrating

    • @extrem2497
      @extrem2497 Před 3 lety +3

      well you learn a lot while you do

    • @GamesWithGabe
      @GamesWithGabe  Před 3 lety +5

      Like ExTrem said you definitely learn a lot while you do. And I have plenty of ceilings that I hit too haha. The hard part is figuring out whether it's worth continuing to try and push past the ceiling or if the problem isn't worth it. Recently I tried to write a C++ parser and I spent about two months on it, and I just decided that it isn't worth continuing since I can just use somebody elses library. But, I still learned a ton from the experience :)

  • @abrahamor4025
    @abrahamor4025 Před 3 lety

    Gabe i have an important question , how i build a jar that runs without errors using gradle ?
    I am a big fan of your work and
    your videos are very helpful, i hope you can answer me.

  • @luandkg
    @luandkg Před 3 lety +1

    Physics 🥰🥰🥰🥰🥰

  • @Andrew-kw6yn
    @Andrew-kw6yn Před 3 lety

    i wish this came out like a year ago when i was making a 2d engine using Warmful development's tutorial which was pretty old and also had a lot of issues and not much explanation

    • @GamesWithGabe
      @GamesWithGabe  Před 3 lety

      I actually did start this series a year ago, but it only had a few episodes then haha. But I'm glad you found it now :)