Unit tests and Line vs Circle | Coding a 2D Physics Engine in Java #6

Опубликовано: 08 Июль 2020
на канале: GamesWithGabe
3,289
103

Join the Discord:   / discord  

In this episode I go over how to tell if a line segment is intersecting with a circle. We use some fancy math to project the vector from the line's beginning to the center of the circle onto the line segment, then we check the length of that against the length of the line. If the length of the circle to beginning of the line segment is less than the lenght of the line segment and greater than zero, then the line is intersecting. I also go over how to create unit tests for all these functions. So, we integrate JUnit, then set up a simple test class, and finally add the test class to our build configuration so that unit tests are run before the program is started every time. This is a good way to ensure that your code doesn't break if you change things in the future.

Source Code: https://github.com/codingminecraft/Ma...

0:00 Intro
0:44 Math behind line vs circle
6:11 Coding line vs circle
10:51 Setting up unit tests

---------------------------------------------------------------------
Website: https://ambrosiogabe.github.io/
Github: https://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: https://www.gameenginebook.com/
Game Physics Cookbook (Read this before the next physics book): https://www.amazon.com/Game-Physics-C...
Game Physics (Ian Millington): https://www.amazon.com/Game-Physics-E...
Game Programming Patterns (Free): https://gameprogrammingpatterns.com/

My Recommended Beginning Game Programming Books:
JavaScript Game Design: https://www.apress.com/gp/book/978143...

My Recommended Java Books:
Data Structures/Algorithms: https://www.amazon.com/Data-Structure...
LWJGL (Free, but I haven't read this thoroughly): https://lwjglgamedev.gitbooks.io/3d-g...

Outro Music: https://www.bensound.com/royalty-free...


Смотрите видео Unit tests and Line vs Circle | Coding a 2D Physics Engine in Java #6 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь GamesWithGabe 08 Июль 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 3,289 раз и оно понравилось 103 людям.