Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Fizzy - A wrapper around JBox2D  (Read 4185 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Posted 2010-10-26 14:51:07 »

I'm putting together a simple wrapper library for JBox2D (it's awesome) that attempts to make it a bit easier to use (a-la Phys2D). So far it simply supports bodies with compound shapes and some basic physics but the code does end up looking pretty simple:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
World world = new World();
     
Body body = new Body(new Circle(10.0f), 0, 0);
world.add(body);
Body floor = new Body(new Rectangle(200.0f, 10.0f), 0, -50.0f, true);
world.add(floor);
     
world.addListener(new WorldListener() {
    @Override
    public void collided(CollisionEvent event) {
        System.out.println("Collision");
    }

    @Override
    public void separated(CollisionEvent event) {
        System.out.println("Separate");
    }
});

for (int i=0;i<4000;i++) {
   world.update(0.01f);
}


If anyone's interested the code is available here: https://bob.newdawnsoftware.com/repos/slick/trunk/fizzy/

And there's an initial jar here: http://www.cokeandcode.com/fizzy/demo/fizzy.jar

And there's rather an indulgent logo that I did because I like logos:



Comments appreciated,

Kev

Offline ewjordan

Junior Member





« Reply #1 - Posted 2010-10-27 18:55:19 »

Brilliant! - a proper wrapper is something that's been on my JBox2d todo list for a long time, I started one for Processing, but never quite got around to finishing it up.  Box2d is great, but it doesn't make much of an effort to make simple things easy to do, and due to time constraints I was never able to move very far away from a strict function-by-function port of the C++, so JBox2d inherited all that complexity.

Great job, I think this will be extremely useful!

Out of curiosity, what license is this under?  I'm thinking that a lot of this could be very useful within the Processing wrapper.
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #2 - Posted 2010-10-27 18:58:16 »

My normal license, I don't really care what you do with it Smiley Lets call it BSD.

Kev

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #3 - Posted 2010-10-27 19:39:49 »

I was thinking of making a similar wrapper like this in Objective-C. I may just use your project as a model. Smiley

See my work:
OTC Software
Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Reply #4 - Posted 2010-10-28 22:11:30 »

How about a high level wrapper for the Box2D native wrapper in libgdx? Smiley

Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #5 - Posted 2010-10-29 11:12:03 »

All sounds good to me! Smiley I'm going to carry on using it for a few demos and add features are they actually become something that is in the 95% of cases category.

Currently debating whether I should provide "cut throughs" so you access the JBox2D data model at your own risk should you feel the need (or should you need an detailed feature of the library). Seems like a good idea but the focus is not confusing developers so um, ar, um ar... Smiley

Kev

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 50
Projects: 15


★★★★★


« Reply #6 - Posted 2010-10-29 11:20:32 »

really cool library, thx. We finally now have a library that has best of both worlds (performance and clean api).

Currently debating whether I should provide "cut throughs" so you access the JBox2D data model at your own risk should you feel the need (or should you need an detailed feature of the library). Seems like a good idea but the focus is not confusing developers so um, ar, um ar... Smiley
Odd, kind of defeats the point, if someone needs that can't they just use the JBox2D library directly?
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #7 - Posted 2010-10-29 11:26:12 »

Yeah, sorta agree. But I also know that there will always be some features that won't get exposed by an abstract high level API. So you could be using it for 90% of your game then realise you want to set some value on the underlying body that Fizzy doesn't show you.

It's similar to Slick letting you drill through and play with OpenGL state as much as you like at your own risk.

Kev

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 437
Projects: 4


Hand over your head.


« Reply #8 - Posted 2010-10-29 18:05:48 »

Yeah, sorta agree. But I also know that there will always be some features that won't get exposed by an abstract high level API. So you could be using it for 90% of your game then realise you want to set some value on the underlying body that Fizzy doesn't show you.

It's similar to Slick letting you drill through and play with OpenGL state as much as you like at your own risk.

Kev

You should absolutely provide access to JBox2D. Just give every Fizzy object a method with an annoying name, not a getter (to prevent autocompletion displaying it).

Something like: Body body = fizzyBody.backing();

Or not.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (34 views)
2013-05-17 21:29:12

alaslipknot (42 views)
2013-05-16 21:24:48

gouessej (72 views)
2013-05-16 00:53:38

gouessej (71 views)
2013-05-16 00:17:58

theagentd (79 views)
2013-05-15 15:01:13

theagentd (74 views)
2013-05-15 15:00:54

StreetDoggy (116 views)
2013-05-14 15:56:26

kutucuk (139 views)
2013-05-12 17:10:36

kutucuk (140 views)
2013-05-12 15:36:09

UnluckyDevil (147 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.1 seconds with 21 queries.