Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
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  
  Verlet Demo Java Source Code  (Read 3913 times)
0 Members and 1 Guest are viewing this topic.
Offline Ranger
« Posted 2010-01-21 07:19:55 »

Hi,



Verlet tutorial:  http://www.gamedev.net/reference/programming/features/verletPhys/default.asp

Verlet Java Code: http://verlet.googlecode.com/

Verlet Demo: http://verlet.googlecode.com/svn/VerletDemo/demo/index.html

Enjoy  Smiley

Tutorial written by Benedikt Bitterli.
Java code ported from Benedikt Bitterli C++ code by me.
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2010-01-21 09:11:37 »

Cool! Why do some of the boxes spin like crazy?

Offline Ranger
« Reply #2 - Posted 2010-01-21 09:29:27 »

Cool! Why do some of the boxes spin like crazy?

Good question.  I noticed it open happens when there is a lot of collisions going on.  I think I have made an error somewhere as the C++ version doesn't seem to do it.  Undecided

EDIT:  And in my version, you can squash the triangles, while in the C++ version you can't.  Maybe I have messed up the mouse handler that moves the vertices.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #3 - Posted 2010-01-21 11:17:00 »

I'm too lazy to look at your code, but are you doing fixed time steps? Unmodified Verlet is unstable otherwise (if memory serves).
Offline Ranger
« Reply #4 - Posted 2010-01-21 11:33:44 »

I'm too lazy to look at your code, but are you doing fixed time steps? Unmodified Verlet is unstable otherwise (if memory serves).

Yep.  Fixed to 30fps with 15 iterations per frame.

EDIT: The spin-of-death always seems to only happen on the box you are dragging, so I'm thinking I have just messed up the mouse handler, and the core verlet code is ok.
Offline pjt33
« Reply #5 - Posted 2010-01-21 11:35:54 »

Cool! Why do some of the boxes spin like crazy?
If you take a screenshot you'll find that they're quite non-square while doing that. I wonder whether if one side gets compressed it generates angular momentum trying to fix it.
Offline Ranger
« Reply #6 - Posted 2010-01-21 23:35:28 »

Think I've now fixed the spin-o-death bug.  This also fixed the ability to squash things.  Now looks exactly like the C++ version.  Let me know if you notice any bugs.  Cheers.
Offline derhannes

Senior Newbie


Projects: 1



« Reply #7 - Posted 2010-01-22 12:06:32 »

Thanks a lot for sharing your code!
Love playing around with it Smiley
I'm trying to add sprites at the moment, I think I'll use this for my planned Jump&Run game.
Offline zammbi

JGO Coder


Medals: 4



« Reply #8 - Posted 2010-01-22 14:25:12 »

Was playing around and it crashed:

Quote
Exception in thread "Thread-12" java.lang.NullPointerException
   at com.gmail.craigmit.verletdemo.Physics.bodiesOverlap(Physics.java:286)
   at com.gmail.craigmit.verletdemo.Physics.iterateCollisions(Physics.java:141)
   at com.gmail.craigmit.verletdemo.Physics.update(Physics.java:293)
   at com.gmail.craigmit.verletdemo.MainApplet.run(MainApplet.java:159)
   at java.lang.Thread.run(Unknown Source)

Current project - Rename and Sort
Offline CommanderKeith
« Reply #9 - Posted 2010-01-22 16:50:05 »

Very nice demo!

Thanks for putting it up on google code  Cool

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ranger
« Reply #10 - Posted 2010-01-22 20:19:31 »

Was playing around and it crashed:


Did you add a lot of boxes?  There's no array bound checking (same with the C++ version).  Will add it in at some point.  Cool

I also noticed that I can get the spin-o-death on the boxes that I add but not on the boxes that are already there.  I'm guessing because the boxes you can add are not square.  But I'm at a loss as to why they spin like that.
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #11 - Posted 2010-01-23 02:06:48 »

Do added boxes spin in the C++ version?

I guess when the boxes are stacked like that, they deform trying to fit and if it happens just right, surrounding boxes push the box away, boxes on the other side push it away, and it spins. Once it gets going, it doesn't stop.

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.

CopyableCougar4 (22 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (27 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (26 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
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!