Can you describe what the messed part is now? After a few code changes, it could be acting differently than it was.why the out put is messed when the for loop is in place
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Can you describe what the messed part is now? After a few code changes, it could be acting differently than it was.why the out put is messed when the for loop is in place
it seems that the ball is containd on one side of the page the balls see as tho they are not flowing more like traped on one side
Back to printing out the values of the balls positions. Only test with two balls to keep it simple. You might try changing the size of the window and the speed that the balls move for easier debugging.like traped on one side
The thing to notice is when the ball reverses direction. What variables are used when a ball reverses direction?
it must be something to do with the for loop because all varibles are the same with and without it and when i put a break; after the while the balls work perfectley hmmmm this is deffonatley a strange one
You can make assumptions and/or you can add printlns and look at the output and see if there is a pattern when a ball looks like it is "trapped on one side".
What are the values of the balls positions when that happens?
here is a print out of the posision
x = 758 y = 547
x = 50 y = 524
x = 757 y = 548
x = 49 y = 525
x = 756 y = 549
x = 48 y = 526
x = 755 y = 550
x = 47 y = 527
x = 754 y = 551
x = 46 y = 528
x = 753 y = 552
x = 45 y = 529
x = 752 y = 553
x = 44 y = 530
x = 751 y = 554
x = 43 y = 531
x = 750 y = 555
x = 42 y = 532
x = 749 y = 556
x = 41 y = 533
x = 748 y = 557
x = 40 y = 534
x = 747 y = 558
x = 39 y = 535
x = 746 y = 559
x = 38 y = 536
x = 745 y = 560
x = 37 y = 537
x = 744 y = 561
x = 36 y = 538
x = 743 y = 562
x = 35 y = 539
x = 742 y = 563
x = 34 y = 540
x = 741 y = 564
x = 33 y = 541
x = 740 y = 565
x = 32 y = 542
x = 739 y = 566
x = 31 y = 543
x = 738 y = 567
x = 30 y = 544
x = 737 y = 568
x = 29 y = 545
x = 736 y = 569
x = 28 y = 546
x = 735 y = 570
x = 27 y = 547
X:\Desktop\Programing Resit#\tests\bb2\test 2\test3>
thats just for one ball
And I assume that the one balll moved as expected. Is that correct?
Now run the test with two balls.
Did you read post#30?
one ball is moving strange too as the print out shows it seems to be on the x axis, i saw post #30 yeah i am going to chenge the window size now
found the problem
for (int i=0; i<opc;i++){
insted of
for (int i=0; i<=opc;i++){
now the balls are moving the same way at the same speed
One more bug out. Maybe three left.
Then a big redesign.
viper_07 (July 10th, 2011)
haha yeah thankyou so much for helping me with this i am most greatfull
Ok, Good luck.
thanks mate