Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 6128 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Posted 2010-10-26 12: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 16: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

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #2 - Posted 2010-10-27 16: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #3 - Posted 2010-10-27 17: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 Kernel


Medals: 147
Projects: 4
Exp: 14 years


Esoteric Software


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

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

Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2010-10-29 09: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: 77
Projects: 15


★★★★★


« Reply #6 - Posted 2010-10-29 09: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

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2010-10-29 09: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

Online Riven
« League of Dukes »

JGO Overlord


Medals: 798
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #8 - Posted 2010-10-29 16: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
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

BurntPizza (13 views)
2014-09-19 03:14:18

Dwinin (31 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (79 views)
2014-09-10 06:39:09

Tekkerue (40 views)
2014-09-09 02:24:56

mitcheeb (62 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (36 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!