PDA

View Full Version : Marble Labyrinth + source code


willThimbleby
2005.03.09, 05:25 AM
Hi, I've just been playing with the Newton physics engine (http://www.idevgames.com/forum/showthread.php?t=8666) and I've put together a weekend hack of a marble labyrinth game. It has a fairly neat fake reflection effect. I thought you'd enjoy playing it and having the source code. It obviously had to support the AMS.

http://www.adlam.plus.com/will/physics/marblelabyrinth.png
http://will.thimbleby.net/physics

let me know what you think. And if any of you have a new powerbook, if the AMS works.

-Will

willThimbleby
2005.03.09, 07:43 AM
If you are interested I just made my reflections more accurate:
http://www.adlam.plus.com/will/physics/reflectold.png --> http://www.adlam.plus.com/will/physics/reflectnew.png

AnotherJake
2005.03.09, 10:35 AM
Wow, that's fantastic! Thanks for the source too Will. I like your programming style. I especially appreciate the comments. I think the friction is set a little high in the labyrinth since it takes quite a bit of tilting compared to the real one to get that marble moving. The sensitivity slider doesn't seem to do anything. But still, it's a very neat demo and helpful example. Keep going!

Disparity
2005.03.09, 08:34 PM
Looks excellent! However, I think the ball is a little on the slow side; the game is a whole lot more frustrating in real life. ;)

On the topic... Any chance you could make a walkthrough explaining how to fix and build the Newton framework?

Disparity
2005.03.09, 08:35 PM
Kudos to Jake... :)

willThimbleby
2005.03.09, 08:36 PM
Thanks! I'm still getting my head round Newton, and haven't figured out how to make it slide faster. Glad you like my programming and the code is useful :) -- there are a couple of large methods for rendering at the moment that need refactoring. And some messy maths mostly due to the fact that I change gravity and move the camera, rather than really tilt the board.

willThimbleby
2005.03.09, 08:40 PM
Yes my game is not frustrating enough :P -- Fixing the Newton framework mostly consists of making sure the xcode project knows where most of the files are. And the resources for the samples need copying into the build folder. Other than that I can't think of anything.

Josh
2005.03.09, 10:28 PM
And as a side-note, I've been playing with Newton all this evening and it is very cool. It's really easy to get things up and running quickly. My only concern is speed.

PowerMacX
2005.03.10, 02:33 AM
Very nice! Just one thing though, on my Rage 128 Pro (16MB) the ball doesn't show up, and the only way to figure out its position (other than playing this as a FPS :p ) is by turning shadows on, but that drops my framerates from 78 to 7.8 :(

willThimbleby
2005.03.10, 04:53 AM
Hmm... that might be because I use a rectangular texture for the ball (which I don't need to) -- try opening up the nib file and making sure the ball window is a square power of 2.

Disparity
2005.03.10, 05:36 PM
Josh
And as a side-note, I've been playing with Newton all this evening and it is very cool. It's really easy to get things up and running quickly. My only concern is speed. Is it slow? :???:

Josh
2005.03.10, 09:23 PM
Is it slow? :???:Will could better attest to this than I, but it seems like the demos run slower than I'd expect. Of course, this is on a 600 MHz G3 iMac and in a game you'd rarely need that many on-screen objects run through the physics engine. What I read on the forum, though, is that, on a whole, it is more accurate than ODE and most other physics engines therefore it is also a little slower.

Edit: and to be fair, their demos seem to be a little odd. Will's tutorial 1 port runs faster than the actual tutorial 1 demo.

willThimbleby
2005.03.11, 08:58 AM
I'll have to do some proper testing, but my initial thoughts are that it is fairly comparable to ODE. My main reasons to choose Newton, are 1) the very nice interface using callbacks (I've found it *much* easier to use than ODE), 2) the much better collision detection with meshes and convex hulls, 3) the fact that there is ongoing development. (version 1.32 has just been released today -- and ODE seems stalled)

I will port the next few demos this weekend and we can see how well they run.

Pearnamer
2005.03.11, 12:19 PM
let me know what you think. And if any of you have a new powerbook, if the AMS works.


Neat game, although it feels like I have to practically turn my laptop over to get the ball to roll. The Y axis seems to be mapped correctly, but the X axis is reversed. (9 March 6 AM build) ie. When I tilt the left side of my laptop down, the ball goes right.

I've got a 15" TiBook, for what it's worth.

maaaaark
2005.03.11, 03:34 PM
That is very very fun. I agree with the speed. It needs to be faster.

With fire balls.

And sporks. :D

willThimbleby
2005.03.11, 07:03 PM
I've tweaked the graphics, and control. It should now be a lot more sensitive although it is not quite what I want yet (I also made the holes bigger :) ). I removed the requirement for rectangular textures - so it should now work for older cards like the Rage128, and I also fixed a major bug with the shadow volume construction -- it is now playable.

I've updated the source code and app (http://will.thimbleby.net/physics)

Great to hear that the AMS works; but I'm not sure what sporks are (they sound dangerous) :p. -- cheers

willThimbleby
2005.03.17, 04:10 PM
Hi, I have released a Cocoa version of the second Newton tutorial. I'm not sure if it is faster than their GLUT example, but it is certainly neater and easier to learn from.

I have also created the same example in ODE. With these you can compare the two physics SDKs performance. These two tutorials are mostly the same, and neither of these has been tuned or tweaked for the respective physics engine.

A main difference was that I was not able to get dynamic timeslicing on ODE working well so it uses a fixed timeslice. My first impressions are that for this example the ODE code is slower; however ODE does need a lot more tweaking. For example, Newton, automatically sleeps bodies, and I haven't switched it on for ODE. Finally after a while of running ODE crashes for me. -- I'm going to stick with Newton. :)

http://will.thimbleby.net/physics

Anybody who wants to chip in on this rough engine comparison please do. Tweaks and improvements can be applied until we have a fair race.

-will