Felt like a hack last night. Hacking is good for motivation, though sometimes not good for focus ;). Theres a few things I'm running in parallel at the moment:

1) Slick - updates and fixes.
2) Networking Library - this is taking a long time. Hopefully be worth it
3) New Applet Game Idea - this is outside of Slick, it's good old Java2D - but it's a winning idea, so heh.

As part of 1) I'm trying to produce a few demos to show how different game types might be started. I'm not planning to write full games but simple tech demos that hopefully give people somewhere to start. As normal I'm trying to make the code useful and readable over making it particually clever.

So, back to this hack, I'd been meaning to take a look at Platformers. Chman had asked how to use Phys2D to make a platformer (though quite a few others had asked before). I realised I hadn't tried it, so all I could do was point him at SlickSet (I know Jon has achieved some cool platformer related stuff).

Anyway, so last night I hacked at some platformer code using phys2d. This is what came out:

You can try it via Webstart and the source available. The code and implementation is expected to develop a bit over the next few days to provide a decent sample, right now it's still buggy - doesn't have good performance - just about trying stuff out.

So why is this hard? It comes down to what I guess is pretty obvious. Generic platformers (think Mario, Sonic, Zool) don't use physics engines, infact they're not even following the rules. When you try and use a physics engine you have to fudge stuff to make it feel more like a traditional platformer while leaving enough of the physics engine intact to allow the rest of the world to make use of the engine (that is of course what we want, a mashup between real physics and platformer dynamics).

Hat's off to Jon, this isn't some tiny task that you can just do. It takes a lot of fiddling. Getting the physics engine to act like a platformer is pretty simple, getting it to allow you to interact with other objects while maintaining the platformer nature - thats a git.

Still, last night I did start from nothing and got the tile combination stuff working, a simple renderer, a tiny engine (named Penguin) and a silly little demo that shows up a lot of the issues. Initial indications are that it's totally possible to mix the two worlds and end up with something uniquely fun.

Hopefully one of the enterprsing folks will take it futher.

Now.. which demo next?

Great stuff!

Great stuff!

Only noticed a little wall-climbing effect when just missing the edge of a platform, but since I always hated the "impossible" jumps in platformers (those were you lose all your lives that you have been saving the last 3 levels, nostalgia mode) I don't really mind. It's fun to push boxes with actual physics instead of single orientation blocks.

An example I would like to see is a topdown sidescroller using physics to handle collisions (maybe not even tile-based). An artist would just be able to draw a scene, import it into the engine and point out the blocking parts. If you have a round pillar and you walk against it, you need to slide around and not stick to the point you collided with it. Add a button to toggle the visibility of the wireframe blocking physics.

Kev: Updated the platformer test to fix some of the niggles. Working on some docs atm.

Nice stuff! A couple

Nice stuff! A couple comments and suggestions for what to tackle next.

- It's interesting that you ignore gravity entirely and basically apply it only if the player's in the air. This is one solution to the not-sliding-down-slope problem, but is this desirable behavior when slopes get steeper?

Now, for the stuff you could tackle next...

- Moving Platforms. The best test is to make one that moves along a closed path, like a circle / polygon with many sides.

- Ladders and Ropes. This should be rather interesting to handle.

- Jump through tiles.

- Water.

- Springboards.

- Add in an "enemy" actor.

- Destructible or dynamic terrain.

Kev: Thanks for the feedback. I'm not that interested in continuing, it's just an example for a couple of others. However, I'm sure they'll be interested in the ideas above.

As to the slopes, yeah, it's interesting one. I guess I'd take it on a game by game basis and tune for that.

Kev, awsome stuff. I took a

Kev, awsome stuff. I took a look and decided to have a little go, got everything running ok and then started messing. Obviously, I wanted to do something which is not in the demo, so I tried a joint.....

maybe you can tell me where I`m going wrong as the 2 crates just fall to the floor unconnected.. thanks
:)

Entity b1 = new Crate(700,100,20,10,5);
env.addEntity(b1);
Entity b2 = new Crate(720,100,20,10,5);
env.addEntity(b2);
new FixedJoint(b1.getBody(),b2.getBody());
Vector2f anchor1=(Vector2f)b1.getBody().getPosition();
Vector2f anchor2=(Vector2f)b2.getBody().getPosition();
new DistanceJoint(b1.getBody(),b2.getBody(), anchor1, anchor2,20);

hope to hear from you soon, you never know, you might rekindle my desire to code :)

Kev: The joints need to be added to the physics world.

like another post i read

like another post i read tonight, something pops into my head soon as i post....

was it simply that i didnt add the joint to the environment?

Kev: Heh, yeah.

I've actually been working

I've actually been working on a platformer using phys2D for the past 3 months, and yes, it's definitely an interesting situation, especially because I want the player to do an almost obscene number of actions, like clinging to ledges and doing blackflips and all kinds of other craziness. I have probably spent half the development time tweaking physics, and there's still a long way to go. But I'm confident to come up with something very cool.

http://www.javagaming.org/forums/index.php?topic=18491.0