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

shrucis1's Comments

Back to shrucis1's profile

Hey bourne, for me the "bourne's scenarios with codes" no longer works, I just see a blank box. If you could fix this, that'd be great.
The big project! :D I take it the code I found no longer works? I'll probably test it out anyways.
Yes, it certainly helps. But seriously, please do upload that project, I know I'm dying of curiosity.
Yeah, I'll leave them remapped, but I can't very well test with your scenario because I don't have the java console configured so I can see it in my browser.
The way you detect repetition is flawed, I'll get a number sequence like so: 114 - 60 - 456 - 240 - 480 - 288 - 576 - 480 - 288 - 576 - 480 - 288... etc., repeating 288, 576, and 480, but the entire thing is red, as though it didn't repeat at all. I imagine it's looking for the next time it sees the value 114 followed by 60... and so on.
Wait, so values 92 and 13 work onsite?
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);
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.
The problem seems to be somewhat that the objects can't accelerate downwards, because if you switch the locations, only the red one moves.