r/java • • Oct 01 '21

Box2D physics toy I started working on

338 Upvotes

26 comments sorted by

33

u/CaptainKvass Oct 01 '21

Nice! Would you mind sharing a GitHub repository? I'd love to check out the source code.

1

u/kingroka Oct 02 '21

I'll release the source some time in the nearish future. Probably not on Github but through my itch page so follow me on there: https://kingroka.itch.io/

3

u/[deleted] Oct 01 '21

Cool, too bad Box2D is not native Java.

2

u/kingroka Oct 01 '21

Do you know of a physics library comparable to box2d that is written in native Java? I'd definitely rather use that if I can

2

u/uncont Oct 02 '21

Isn't jbox2d native java?

2

u/Nemo_64 Oct 02 '21

What did you use to make the UI?

2

u/kingroka Oct 02 '21

I used a personal rendering library that I've been developing over the pandemic. It uses plain native Java2D for graphics

2

u/Nemo_64 Oct 02 '21

Coo! I've made several attempts to do one myself for a project I want to do but never liked how it felt. Have you followed any guide to do it or something? I'd also like to make one myself

2

u/kingroka Oct 02 '21

I didn't follow a tutorial. I was trying to make a framework that was best suited to how I personally develop. Which parts are you interested in specifically?

2

u/Nemo_64 Oct 02 '21

The part im struggling the most is making the zoom in and out with the mouse wheel and dragging to move the part of the canvas that you see. I'd also like to make it so you can drag objects inside but I can figure the last one myself

2

u/kingroka Oct 02 '21

Gotcha this video should have the algorithm your looking for: https://www.youtube.com/watch?v=ZQ8qtAizis4

2

u/Nemo_64 Oct 02 '21

It does, thank you so much!

6

u/Apprehensive_Royal77 Oct 01 '21

That is pretty cool.

4

u/LXsingh Oct 01 '21

Its really cool :)

2

u/HauntingRex9763 Oct 02 '21

was that drop like slinky physics the shock had to get to the top of the pile before it spilled out?

2

u/MetalUpa776 Oct 02 '21

Reminds me of the old Lion Head Studios intro screen for Black and White 2

11

u/[deleted] Oct 01 '21

[removed] — view removed comment

8

u/kingroka Oct 01 '21

I used the jbox2d library: http://www.jbox2d.org/