This site requires JavaScript, please enable it in your browser!
Greenfoot back

Comments for Gravity Sim

Return to Gravity Sim

shrucis1shrucis1

2013/12/30

The problem seems to be somewhat that the objects can't accelerate downwards, because if you switch the locations, only the red one moves.
shrucis1shrucis1

2013/12/30

By the way, there's no shortage of gravity simulation scenarios on greenfoot, which was something I realized and influenced my decision not to post mine.
shrucis1shrucis1

2013/12/30

Figured it out! It's quite obvious really, when you think of why only negative accelerations have any impact... until the acceleration is larger than a whole number. Your x and y location variables are integers, so when you add 0.05 to integer 5, you still have 5, because when you get 5.05, it's truncated back to an integer, so it just takes 5 off of 5.05. When you subtract 0.05, you get 4.95, which when truncated yields 4. The simple solution to this is to make your x and y location variables doubles, and whenever you do setlocation, do it like so: setLocation((int)x, (int)y);
A new version of this scenario was uploaded on Mon Dec 30 23:55:07 UTC 2013 Fixed a bug Added collisions Can add objects
A new version of this scenario was uploaded on Tue Dec 31 00:17:42 UTC 2013 Fixed bug Collisions still a bit buggy can now remove objects
A new version of this scenario was uploaded on Tue Dec 31 00:36:24 UTC 2013 Randomly generated example Can now clear all objects using 'c'
A new version of this scenario was uploaded on Tue Dec 31 01:06:12 UTC 2013 Fixed Collision
A new version of this scenario was uploaded on Tue Dec 31 01:48:49 UTC 2013 bug fix
A new version of this scenario was uploaded on Tue Dec 31 10:39:12 UTC 2013 Can now zoom in and out
A new version of this scenario was uploaded on Tue Dec 31 13:42:14 UTC 2013 fixed a bug
A new version of this scenario was uploaded on Wed Jan 01 14:06:20 UTC 2014 fixed some bugs added more collisions -you can switch between collision types using 'z'
A new version of this scenario was uploaded on Wed Jan 01 19:30:29 UTC 2014 Now starts off with a solar system.
A new version of this scenario was uploaded on Tue Jan 28 19:11:40 UTC 2014 Fixed stick collision Now starts off with a binary star system
A new version of this scenario was uploaded on Wed Jan 29 18:30:14 UTC 2014 simplified code
A new version of this scenario was uploaded on Thu Jan 30 18:42:56 UTC 2014 fixed a bug
A new version of this scenario was uploaded on Tue Feb 04 18:58:21 UTC 2014 you can now pause and add/remove objects with 'p'
A new version of this scenario was uploaded on Wed Feb 05 17:54:53 UTC 2014 Now has a starry background
A new version of this scenario was uploaded on Wed Feb 05 17:56:17 UTC 2014 Now has a starry background
Game/maniacGame/maniac

2014/2/13

Is there anything else I should add?
Game/maniacGame/maniac

2014/2/20

Is there anything I can add so more people will like this?
A new version of this scenario was uploaded on 2016-07-31 17:28:44 UTC Fixed bouncing collision types Next update will include: better motion better UI
A new version of this scenario was uploaded on 2016-07-31 17:31:18 UTC Updated tags
NichodonNichodon

2016/8/1

When "stick" is enabled, does it treat the objects as one object?
Game/maniacGame/maniac

2016/8/1

When "stick" is enabled objects appear to become one object, but really they act separately, however because of this if you have three objects stuck together, there will be a wired glitch where momentum is gained even though it should be conservered.
Game/maniacGame/maniac

2016/8/1

*Conserved